我只是想将我的项目从 targetSDK 版本 33 更新到 34。为此,我还需要更新一些生命周期 api。以前我用过这些版本
//LifeCycle
implementation 'androidx.lifecycle:lifecycle-common:2.2.0'
implementation 'androidx.lifecycle:lifecycle-runtime:2.2.0'
implementation 'android.arch.lifecycle:extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
我更新了
//LifeCycle
def lifecycle_version = "2.8.3"
def arch_version = "2.2.0"
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// Lifecycles only (without ViewModel or LiveData)
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
// Saved state module for ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version"
// Annotation processor
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
但现在它显示出我不理解的错误。
错误
* 任务:app:mergeExtDexDebug 失败 AGPBI: {“种类”:“错误”,“文本”:“java.lang.NullPointerException”,“来源”:[{“文件”:“/Users/apple/.gradle/caches/trans forms-3/826f48ce73a7e66fbb6d1694a1db726c/transformed/lifecycle-livedata-core-2.8.3-runtime.jar"}],"工具":"D8"} *
我已经尝试过的:
如果有人遇到这个问题或有任何想法,请帮助我。谢谢
两种方法:
更新项目以使用 AGP 8.4.0 或更高版本。 参考
将lifecycle_version降级至2.7.0