相关疑难解决方法(0)

将 Jetpack Compose 升级到 1.0.0?beta07 后出现 java.lang.NoSuchMethodError

observeAsState将 Jetpack Compose 升级到 1.0.0?beta07 后,在 LiveData 对象上运行时出现以下错误。

java.lang.NoSuchMethodError: No interface method startReplaceableGroup(ILjava/lang/String;)V in class Landroidx/compose/runtime/Composer; or its super classes
Run Code Online (Sandbox Code Playgroud)

文档说升级时会出现错误,为了解决它,必须重新编译依赖于 Compose 的库。

我不知道必须这样做。我尝试再次制作该项目,也无济于事地清除和重建它。

这是我项目中的依赖项:

dependencies {
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0-alpha01'
    implementation 'androidx.activity:activity-compose:1.3.0-alpha07'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
    implementation "io.github.vanpra.compose-material-dialogs:datetime:0.4.0"
    implementation "io.github.vanpra.compose-material-dialogs:datetime:0.4.0"
    implementation "androidx.appcompat:appcompat:$appCompatVersion"
    implementation "androidx.activity:activity-ktx:$activityVersion"
    implementation "androidx.room:room-ktx:$roomVersion"
    kapt "androidx.room:room-compiler:$roomVersion"
    androidTestImplementation "androidx.room:room-testing:$roomVersion"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.30"
    api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines"
    api …
Run Code Online (Sandbox Code Playgroud)

android android-livedata android-jetpack-compose

24
推荐指数
2
解决办法
2880
查看次数