【问题标题】:I cannot upgrade Compose from 1.1.1 to 1.2.0我无法将 Compose 从 1.1.1 升级到 1.2.0
【发布时间】:2022-08-16 01:57:06
【问题描述】:

您好,我正在使用 Compose 1.1.1 开发一个新应用程序,我想将其升级到 1.2.0 版。我正在使用org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0,这似乎是问题所在。 这是错误:

Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration \':app:debugRuntimeClasspath\'.

还有这个:

Caused by: org.gradle.api.GradleException: Cannot find a version of \'org.jetbrains.kotlinx:kotlinx-coroutines-core\' that satisfies the version constraints:

这些是我正在使用的依赖项:

dependencies {

//Hilt dependency injection
implementation(\"com.google.dagger:hilt-android:$hilt_version\")
kapt(\"com.google.dagger:hilt-android-compiler:$hilt_version\")
implementation \"androidx.hilt:hilt-navigation-compose:1.0.0\"
implementation \"androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03\"

//Realm Mongo implementation
implementation \'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-native-mt\'
implementation \'io.realm.kotlin:library-sync:1.0.1\'
implementation(\"io.coil-kt:coil-compose:1.4.0\")

implementation \'androidx.core:core-ktx:1.7.0\'
implementation \"androidx.compose.ui:ui:$compose_version\"
implementation \"androidx.compose.material:material:$compose_version\"
implementation \"androidx.compose.ui:ui-tooling-preview:$compose_version\"
implementation \'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1\'
implementation \'androidx.activity:activity-compose:1.3.1\'
testImplementation \'junit:junit:4.13.2\'
androidTestImplementation \'androidx.test.ext:junit:1.1.3\'
androidTestImplementation \'androidx.test.espresso:espresso-core:3.4.0\'
androidTestImplementation \"androidx.compose.ui:ui-test-junit4:$compose_version\"
debugImplementation \"androidx.compose.ui:ui-tooling:$compose_version\"
}
  • 你有什么理由不使用最新的 Kotlin 1.7 版?与 Java 等其他一些语言不同,Kotlin 不保持与旧版本的向后兼容性。尝试始终使用最新版本是最安全的,因此如果您稍后升级版本,代码中行为更改的可能性会更小。此外,如果您尝试使用旧版本,您将只能使用您使用的任何基于 Kotlin 的库的旧版本,正如您在协程中发现的那样。
  • @Tenfour04 我的问题打错了,因为实际上我正在使用 Compose,所以我想升级到最新版本的 compose。我对此感到抱歉。
  • 如果它是 android 应用程序,请尝试添加此 org.jetbrains.kotlinx:kotlinx-coroutines-android:$version 而不是 core
  • @Sylwek845 我试过这个但没用

标签: android kotlin gradle mobile kotlin-coroutines


【解决方案1】:

这是因为依赖关系冲突。撰写1.2.0想要获得协程1.6.1而你的领域依赖有1.6.0-native-mt这是较低的,并且似乎他们放置了一系列可以使用的严格版本 - 又名不推荐使用的force = true(找不到任何东西,可能 bc Realm 不是开源项目,但 Gradle 给出了提示)。我检查了一个变更日志,根据this Realm 与更高版本不兼容,还没有计划。

在您的情况下,您还可以强制下载的依赖项

 implementation ('org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0-native-mt') {
    version {
        strictly '1.6.0-native-mt'
    }
}

您的项目很可能会成功构建。但老实说 - 我不知道它会对 Compose 产生什么影响,我认为不会,但谁知道呢?所以它看起来像一个权衡:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-31
    • 2018-07-31
    • 2020-12-10
    相关资源
    最近更新 更多