将JetpackCompose升级到1.0.0?beta07后出现java.lang.NoSuchMethodErrorstartRestartGroup

我刚刚将撰写版本更新为 1.0.0?beta07,并显示了此运行时错误

No interface method startRestartGroup(ILjava/lang/String;)Landroidx/compose/runtime/Composer; in class Landroidx/compose/runtime/Composer; or its super classes (declaration of 'androidx.compose.runtime.Composer' 
....
 at com.google.accompanist.coil.CoilImage__CoilKt.CoilImage(Coil.kt:245)
        at com.google.accompanist.coil.CoilImage.CoilImage(Coil.kt:1)

下面是我的 gradle 依赖文件

implementation 'androidx.core:core-ktx:1.5.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'

    implementation "androidx.compose.compiler:compiler:$compose_version"
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation "androidx.compose.runtime:runtime:$compose_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"

    implementation 'androidx.activity:activity-compose:1.3.0-alpha08'
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha05"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'

    implementation "io.coil-kt:coil-gif:1.2.1"
    implementation "io.coil-kt:coil-svg:1.2.1"
    implementation "com.google.accompanist:accompanist-coil:0.6.2"

和版本 compose_version = '1.0.0-beta07'

回答

beta07根据Compose 发行说明,每个库都需要重新编译才能工作:

注意:依赖 Compose 的库需要使用 1.0.0?beta07 版重新编译。否则,库可能会遇到NoSuchMethodError,例如:
java.lang.NoSuchMethodError: No interface method startReplaceableGroup(ILjava/lang/String;)V in class Landroidx/compose/runtime/Composer; or its super classes. (Ia34e6)

在您的情况下,您必须使用0.10.0.

改变:

implementation "com.google.accompanist:accompanist-coil:0.6.2"

implementation "com.google.accompanist:accompanist-coil:0.10.0"

  • good answer, last version:
    implementation "com.google.accompanist:accompanist-coil:0.11.0"

以上是将JetpackCompose升级到1.0.0?beta07后出现java.lang.NoSuchMethodErrorstartRestartGroup的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>