app:checkDebugDuplicateClasses
app:checkDebugDuplicateClasses中androidx.lifecycle重复解决方案
·
项目中遇到androidx.lifecycle依赖重复

我的gradle版本:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zipb并不是版本低的问题
我的依赖注入一开始没有加入androidx.lifecycle:

这里可能是某个依赖项使用科特林的版本视图模型库,而您的代码使用爪哇版本。指定两者要强制所有依赖项的最新版本
有人认为消除此重复类比较好,使用了:
configurations {
all {
exclude group: 'androidx.lifecycle', module: 'lifecycle-viewmodel-ktx'
}
}
将androidx.lifecycle改为最新版本也可以解决这个问题:
implementation "androidx.lifecycle:lifecycle-viewmodel:2.5.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
这里我使用的解决方案是加入:
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
更多推荐



所有评论(0)