Android Studio 3.4.1集成MaterialProgressBar库报错求助
解决方案:AndroidX与Support库冲突导致的Manifest合并失败
我来帮你解决这个问题——你遇到的Manifest合并冲突确实是因为AndroidX和旧Support库不兼容导致的,具体原因和解决方案如下:
问题根源
me.zhanghai.android.materialprogressbar:library:1.6.1 这个版本从1.5.0开始就已经完全迁移到AndroidX了,而你的项目仍然使用的是旧版的com.android.support系列依赖,两者的组件命名、资源文件存在冲突,直接导致Manifest合并失败。
方案一:迁移项目到AndroidX(推荐)
由于Google已经停止对Support库的维护,迁移到AndroidX是长期的解决方案,步骤如下:
- 打开Android Studio,依次点击菜单栏的
Refactor > Migrate to AndroidX... - 按照向导提示完成迁移,工具会自动将所有Support库依赖替换为对应的AndroidX依赖
- 迁移完成后,你的
build.gradle(Module级别)依赖会更新为类似以下内容:implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'com.google.android.material:material:1.9.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.recyclerview:recyclerview:1.3.2' implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - 点击
Sync Now同步项目,冲突问题即可解决
方案二:使用该库的Support兼容版本(临时方案)
如果暂时不想迁移AndroidX,可以改用该库最后一个基于Support库的版本,将依赖替换为:
implementation 'me.zhanghai.android.materialprogressbar:library:1.4.2'
这个版本完全兼容你当前的com.android.support系列依赖,不会出现Manifest合并冲突。
内容的提问来源于stack exchange,提问作者Anh Huynh
相关产品推荐
相关产品推荐

