android 将Jetpack合成升级到1.0.0‑beta07后出现java.lang.NoSuchMethodError

p1iqtdky  于 2022-12-21  发布在  Android
关注(0)|答案(8)|浏览(166)

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

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

文档说明升级时会出现错误,为了解决它,必须重新编译依赖于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 "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines"
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta06'
    implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha07"
}

这些是版本:

ext {
        compose_version = '1.0.0-beta07'
        activityVersion = '1.1.0'
        appCompatVersion = '1.2.0'
        constraintLayoutVersion = '2.0.2'
        coreTestingVersion = '2.1.0'
        coroutines = '1.3.9'
        lifecycleVersion = '2.3.1'
        materialVersion = '1.2.1'
        roomVersion = '2.3.0'
    }
ebdffaop

ebdffaop1#

任何使用Navigation with compose的人还应该将导航库更新到最新的可用版本。
就我而言,我用的是

implementation "androidx.navigation:navigation-compose:1.0.0-alpha10"

不得不用

implementation "androidx.navigation:navigation-compose:2.4.0-alpha01"
g52tjvyc

g52tjvyc2#

您的runtime-livedata依赖项已过时:

implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta06'

您应该更新它以使用与其余合成依赖项相同的版本:

implementation "androidx.compose.runtime:runtime-livedata:$compose_version"

这将有效地:

implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta07'
qyswt5oh

qyswt5oh3#

对我有效的是更新到

implementation("androidx.hilt:hilt-navigation-compose:1.0.0-alpha02")

以及

implementation("com.google.accompanist:accompanist-swiperefresh:0.10.0")
ykejflvf

ykejflvf4#

对我来说,它是将约束布局合成版本更新为1.0.0-alpha07androidx.constraintlayout:constraintlayout-compose:$constraint_layout_version

5t7ly7z5

5t7ly7z55#

需要将分页组成从1.0.0-alpha 07更新为1.0.0-alpha 11

implementation "androidx.paging:paging-compose:1.0.0-alpha11"
jvlzgdj9

jvlzgdj96#

我通过添加这个依赖项解决了这个问题-

implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07'
uajslkp6

uajslkp67#

通过使用以下方法解决了该问题

def compose_version = '1.0.1'
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
g52tjvyc

g52tjvyc8#

老实说,有时删除和重新编写有问题的组件会有帮助。对我来说,它在可组合程序中的某个可选参数上崩溃了。我删除了参数并重新编写了它,然后它就工作了...

相关问题