Мне интересно, можно ли создать библиотеку мультиплатформы Kotlin, которая содержит композицию, расположенную на SRC Androidmain. Со следующей build.gradle.kts (почти по умолчанию) я получаю эту ошибку: < /p>
build.gradle.kts:
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidKotlinMultiplatformLibrary)
alias(libs.plugins.composeCompiler)
alias(libs.plugins.kotlinx.serialization)
}
kotlin {
// Target declarations - add or remove as needed below. These define
// which platforms this KMP module supports.
// See: https://kotlinlang.org/docs/multiplatform-discover-project.html#targets
androidLibrary {
namespace = "com.grumpyshoe.poc.feature.feature_dashboard"
compileSdk = 35
minSdk = 26
withHostTestBuilder {
}
withDeviceTestBuilder {
sourceSetTreeName = "test"
}.configure {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
// For iOS targets, this is also where you should
// configure native binary output. For more information, see:
// https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks
// A step-by-step guide on how to include this library in an XCode
// project can be found here:
// https://developer.android.com/kotlin/multiplatform/migrate
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach { iosTarget ->
iosTarget.binaries.framework {
baseName = "feature_dashboardKit"
isStatic = true
}
}
// Source set declarations.
// Declaring a target automatically creates a source set with the same name. By default, the
// Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is
// common to share sources between related targets.
// See: https://kotlinlang.org/docs/multiplatform-hierarchy.html
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlin.stdlib)
// Add KMP dependencies here
}
}
commonTest {
dependencies {
implementation(libs.kotlin.test)
}
}
androidMain {
dependencies {
implementation(platform(libs.compose.bom))
implementation(libs.compose.compiler)
implementation(libs.compose.ui)
implementation(libs.compose.ui.tooling)
implementation(libs.compose.ui.tooling.preview)
implementation(libs.compose.material3)
implementation(libs.compose.runtime)
implementation(libs.compose.navigation)
implementation(libs.androidx.lifecycle.runtime.compose)
implementation(libs.kotlinx.serialization.json)
// Add Android-specific dependencies here. Note that this source set depends on
// commonMain by default and will correctly pull the Android artifacts of any KMP
// dependencies declared in commonMain.
}
}
getByName("androidDeviceTest") {
dependencies {
implementation(libs.compose.compiler)
implementation(libs.compose.runtime)
implementation(libs.compose.navigation)
implementation(libs.androidx.runner)
implementation(libs.androidx.core)
implementation(libs.androidx.test.junit)
}
}
iosMain {
dependencies {
// Add iOS-specific dependencies here. This a source set created by Kotlin Gradle
// Plugin (KGP) that each specific iOS target (e.g., iosX64) depends on as
// part of KMP’s default source set hierarchy. Note that this source set depends
// on common by default and will correctly pull the iOS artifacts of any
// KMP dependencies declared in commonMain.
}
}
}
}
< /code>
Ошибка: < /h1>
Cannot convert the provided notation to an object of type Dependency:
map(valueof(DependencyValueSource)).
The following types/formats are supported:
- String or CharSequence values, for example 'org.gradle:gradle-core:1.0'.
- Maps, for example [group: 'org.gradle', name: 'gradle-core', version: '1.0'].
- FileCollections, for example files('some.jar', 'someOther.jar').
- Projects, for example project(':some:project:path').
- ClassPathNotation, for example gradleApi().
Я не мог найти ничего в соответствии с такой настройкой, поэтому я подумал, что в этом сообществе кто -то может узнать больше об этом.
Мне интересно, можно ли создать библиотеку мультиплатформы Kotlin, которая содержит композицию, расположенную на SRC Androidmain. Со следующей build.gradle.kts (почти по умолчанию) я получаю эту ошибку: < /p> build.gradle.kts: [code] plugins { alias(libs.plugins.kotlinMultiplatform) alias(libs.plugins.androidKotlinMultiplatformLibrary) alias(libs.plugins.composeCompiler) alias(libs.plugins.kotlinx.serialization) }
kotlin {
// Target declarations - add or remove as needed below. These define // which platforms this KMP module supports. // See: https://kotlinlang.org/docs/multiplatform-discover-project.html#targets androidLibrary { namespace = "com.grumpyshoe.poc.feature.feature_dashboard" compileSdk = 35 minSdk = 26
// For iOS targets, this is also where you should // configure native binary output. For more information, see: // https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks
// A step-by-step guide on how to include this library in an XCode // project can be found here: // https://developer.android.com/kotlin/multiplatform/migrate
// Source set declarations. // Declaring a target automatically creates a source set with the same name. By default, the // Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is // common to share sources between related targets. // See: https://kotlinlang.org/docs/multiplatform-hierarchy.html sourceSets { commonMain { dependencies { implementation(libs.kotlin.stdlib) // Add KMP dependencies here } }
implementation(platform(libs.compose.bom)) implementation(libs.compose.compiler) implementation(libs.compose.ui) implementation(libs.compose.ui.tooling) implementation(libs.compose.ui.tooling.preview) implementation(libs.compose.material3) implementation(libs.compose.runtime) implementation(libs.compose.navigation) implementation(libs.androidx.lifecycle.runtime.compose) implementation(libs.kotlinx.serialization.json) // Add Android-specific dependencies here. Note that this source set depends on // commonMain by default and will correctly pull the Android artifacts of any KMP // dependencies declared in commonMain. } }
iosMain { dependencies { // Add iOS-specific dependencies here. This a source set created by Kotlin Gradle // Plugin (KGP) that each specific iOS target (e.g., iosX64) depends on as // part of KMP’s default source set hierarchy. Note that this source set depends // on common by default and will correctly pull the iOS artifacts of any // KMP dependencies declared in commonMain. } } }
} < /code> Ошибка: < /h1> Cannot convert the provided notation to an object of type Dependency: map(valueof(DependencyValueSource)). The following types/formats are supported: - String or CharSequence values, for example 'org.gradle:gradle-core:1.0'. - Maps, for example [group: 'org.gradle', name: 'gradle-core', version: '1.0']. - FileCollections, for example files('some.jar', 'someOther.jar'). - Projects, for example project(':some:project:path'). - ClassPathNotation, for example gradleApi(). [/code] Я не мог найти ничего в соответствии с такой настройкой, поэтому я подумал, что в этом сообществе кто -то может узнать больше об этом.
В KMM у нас есть build.gradle.kts для общего модуля, который включает, среди прочего:
sourceSets { val commonMain, получив { зависимости { //поместите сюда свои мультиплатформенные зависимости // ... } } val androidMain, получив { // обратите...
У меня есть фрагмент. который я изменил, чтобы использовать экран для сочинения JetPack, и на этом экране я передаю ViewModel, которая использует Dagger 2 для такого введения зависимости.
private val languageViewModel by lazy {...
Здравствуйте, я попытался запустить файл Kotlin в Android Studio (версия 4.1) и получил ошибку: Библиотека Kotlin {0} скомпилирована с помощью более нового компилятора Kotlin и не может быть прочитана. Пожалуйста, обновите плагин Kotlin.
В настоящее время я работаю над проектом с использованием Compose Multiplatform и ищу способы управления функцией видеоплеера по URL-адресу или локальному пути. Однако, поскольку ExoPlayer не поддерживается на стороне IOS, я не нашел решения....
В PhotoSwipe 5 UI-Elements я хочу создать функцию, которой необходим доступ к текущему источнику данных изображения. Я не знаю, как получить URL-адрес источника данных текущего изображения. Есть ли у кого-нибудь пример кода? С уважением.