引入三方SDK出現(xiàn):Duplicate class com.xxx.xxx found in modules
例如:Duplicate class org.apache.commons.codec.BinaryDecoder found in modules jetified-commons-codec-1.5.jar (commons-codec:commons-codec:1.5) and jetified-org.apache.http.legacy.jar (org.apache.http.legacy.jar)
翻譯:在jetified-commons-codec-1.5.jar(commons codec:commons codec:1.5)和jetified-org.apache.http.legacy.jar(org.apache.http.legacy.jar)模塊中找到重復(fù)的org.apache.commons.codec.BinaryDecoder類
解決:
? ? 一竞思、定位。
Android studio - Navigate-Class-搜索重復(fù)的類
二埂蕊、點(diǎn)開重復(fù)的jar篮绰,處理
? ? 1魂拦、如jar無(wú)用可直接刪除召调。
? ? 2始腾、用 解決,就是去掉 你不需要的類 如:
? implementation ('com.squareup.retrofit2:converter-gson:2.3.0'){
? ? ? ? ?exclude group:'com.google.code.gson'
? ? ? ? ?exclude group: 'com.squareup.okhttp3'
? ? ? ?}
或者?
????exclude module:'glide'
三梭冠、如果依然無(wú)效诸蚕,則改變?nèi)綆?kù)內(nèi)的jar的引入方式步势。
????????這時(shí)候需要將implementation fileTree(dir:'libs',include: ['*.jar']) 去掉。
????????單獨(dú)引用jar背犯,將沖突改為compileOnly;荡瘛!D骸倔矾!