java.lang.NoSuchMethodError 将 Jetpack Compose 升级到 1.0.0‑beta07 后
java.lang.NoSuchMethodError after upgrading Jetpack Compose to 1.0.0‑beta07
将 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
The documentation 表示升级时会出现错误,为了解决它,必须重新编译依赖于 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'
}
您的 runtime-livedata
依赖项已过时:
implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta06'
您应该更新它以使用与其余 Compose 依赖项相同的版本:
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
哪个有效:
implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta07'
任何使用 Navigation with compose 的人也应该将导航库更新到最新的可用版本。
就我而言,我使用的是
implementation "androidx.navigation:navigation-compose:1.0.0-alpha10"
必须替换为
implementation "androidx.navigation:navigation-compose:2.4.0-alpha01"
对我有用的是更新到
implementation("androidx.hilt:hilt-navigation-compose:1.0.0-alpha02")
和
implementation("com.google.accompanist:accompanist-swiperefresh:0.10.0")
对我来说,它正在将约束布局组合版本更新为 1.0.0-alpha07
androidx.constraintlayout:constraintlayout-compose:$constraint_layout_version
从 1.0.0-alpha07 更新到 1.0.0-alpha11 需要分页撰写
implementation "androidx.paging:paging-compose:1.0.0-alpha11"
我已经通过添加这个依赖解决了它-
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07'
使用
解决了
def compose_version = '1.0.1'
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
将 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
The documentation 表示升级时会出现错误,为了解决它,必须重新编译依赖于 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'
}
您的 runtime-livedata
依赖项已过时:
implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta06'
您应该更新它以使用与其余 Compose 依赖项相同的版本:
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
哪个有效:
implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-beta07'
任何使用 Navigation with compose 的人也应该将导航库更新到最新的可用版本。
就我而言,我使用的是
implementation "androidx.navigation:navigation-compose:1.0.0-alpha10"
必须替换为
implementation "androidx.navigation:navigation-compose:2.4.0-alpha01"
对我有用的是更新到
implementation("androidx.hilt:hilt-navigation-compose:1.0.0-alpha02")
和
implementation("com.google.accompanist:accompanist-swiperefresh:0.10.0")
对我来说,它正在将约束布局组合版本更新为 1.0.0-alpha07
androidx.constraintlayout:constraintlayout-compose:$constraint_layout_version
从 1.0.0-alpha07 更新到 1.0.0-alpha11 需要分页撰写
implementation "androidx.paging:paging-compose:1.0.0-alpha11"
我已经通过添加这个依赖解决了它-
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07'
使用
解决了def compose_version = '1.0.1'
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"