1、現(xiàn)在大部分的項目都是支持 Androidx 的,所以出現(xiàn) Duplicate 的時候
先把 gradle.properties 文件中添加參數(shù),支持使用AndroidX
android.useAndroidX=true
android.enableJetifier=true
2、有些 *.jar/*.aar 不支持 AndroidX 的時候,將上面的禁用
然后再排除 AndroidX 的引用
?
configurations{
all*.exclude group: 'androidx.*.*'
...
}
有很多,搜索一下?androidx 就能找到
3、排除了Androidx 的沖突后,包還有沖突?
類似 v4. com 這種
1、先看看沖突的是哪個包,在Android studio? Project 中的 External Libraries 中
?這種基本都是在 app->build.gradle 文件中?implementation 導(dǎo)入進(jìn)去的
所以要排除導(dǎo)入包中的 某個沖突的模塊
?文章來源:http://www.zghlxwxcb.cn/news/detail-408509.html
implementation ('com.android.support:multidex:1.0.1') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
要是沖突的包比較多只能先刪除本地的 jar 文件了。要是舍不得那就一個個去排除。文章來源地址http://www.zghlxwxcb.cn/news/detail-408509.html
到了這里,關(guān)于解決 Android 開發(fā)過程中 出現(xiàn) Duplicate class(包沖突)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!