kotlin Koin库未在多平台项目中编译

fkaflof6  于 2022-11-16  发布在  Kotlin
关注(0)|答案(1)|浏览(195)

我想在多平台项目中使用koin库进行DI,但是在构建项目时出现了一些错误。如何修复这些错误?
我得库:

object Koin {
    private const val version = "3.2.2"
    private const val koin_android_compose_version= "3.2.1"
    private const val koin_android_version= "3.2.2"

    const val koinCore = "io.insert-koin:koin-core:${version}"
    const val koinTest = "io.insert-koin:koin-test:${version}"
    const val koinAndroid = "io.insert-koin:koin-android:${version}"

    const val koinNavigation = "io.insert-koin:koin-androidx-navigation:${koin_android_version}"
    const val koinWorkManager = "io.insert-koin:koin-androidx-workmanager:$koin_android_version"
    const val koinCompose = "io.insert-koin:koin-androidx-compose:$koin_android_compose_version"

    const val koinJUnit4= "io.insert-koin:koin-test-junit4:$version"
}

我的机器人等级:

with(Koin) {
        implementation(koinCore)
        testImplementation(koinTest)
        testImplementation(koinJUnit4)
        implementation(koinAndroid)
        implementation(koinNavigation)
        implementation(koinWorkManager)
        implementation(koinCompose)
    }

k2arahey

k2arahey1#

我修好了它:
我必须排 debugging 误所告知的两个库:

implementation(koinAndroid){
            exclude("androidx.lifecycle", "lifecycle-viewmodel")
            exclude("androidx.lifecycle", "lifecycle-livedata-core")
        }

   implementation(koinWorkManager){
            exclude("androidx.lifecycle", "lifecycle-viewmodel")
            exclude("androidx.lifecycle", "lifecycle-livedata-core")
        }

所有koin依赖项:

with(Koin) {
        implementation(koinCore)
        testImplementation(koinTest)
        testImplementation(koinJUnit4)
        implementation(koinAndroid){
            exclude("androidx.lifecycle", "lifecycle-viewmodel")
            exclude("androidx.lifecycle", "lifecycle-livedata-core")
        }
        implementation(koinNavigation)
        implementation(koinWorkManager){
            exclude("androidx.lifecycle", "lifecycle-viewmodel")
            exclude("androidx.lifecycle", "lifecycle-livedata-core")
        }
        implementation(koinCompose)
    }

相关问题