Поэтому мне нужно было настроить kapt и следовать инструкциям Kmp в Kapt, в результате чего получился следующий файл build.gradle:
Код: Выделить всё
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.androidKotlinMultiplatformLibrary)
alias(libs.plugins.kapt)
}
kotlin {
androidLibrary {
namespace = com.poc.shared"
compileSdk = 36
minSdk = 24
withJava()
withHostTestBuilder {
}
withDeviceTestBuilder {
sourceSetTreeName = "test"
}.configure {
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
}
sourceSets {
commonMain {
dependencies {
implementation(libs.kotlin.stdlib)
}
}
commonTest {
dependencies {
implementation(libs.kotlin.test)
}
}
androidMain {
dependencies {
implementation(libs.dagger)
}
}
}
}
dependencies {
kapt(libs.dagger.compiler)
}
Код: Выделить всё
Versions off plugins:
agp = "8.13.0"
composeMultiplatform = "1.9.0"
kotlin = "2.2.20"
kotlinStdlib = "2.2.20"
dagger = "2.57.2"
Код: Выделить всё
Execution failed for task ':shared:kaptAndroidMain'.
> Cannot query the value of this provider because it has no value available.
Я пробовал использовать kapt в других контекстах, например. установка его в исходном коде androidMain:
Код: Выделить всё
androidMain {
dependencies {
implementation(libs.dagger)
configurations.getByName("kapt").dependencies.add(
DefaultExternalModuleDependency(
"com.google.dagger",
"dagger-compiler",
"2.57.2"
)
)
}
}
Мой вопрос: как мне решить эти проблемы и правильно настроить Dagger для KMP Android?
Подробнее здесь: https://stackoverflow.com/questions/797 ... tiplatform
Мобильная версия