【发布时间】: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