com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex錯誤的解決

在項目中添加了以下依賴之後,運行就發生了報錯

我的項目的依賴:

 implementation ('cn.leancloud:storage-android:6.4.4'){
        exclude group: 'com.alibaba', module: 'fastjson'
        exclude group: 'org.ligboy.retrofit2', module: 'converter-fastjson'

//        exclude group:  'com.squareup.retrofit2',module:'retrofit'
//        exclude group:  'io.reactivex.rxjava2',module:'rxandroid'
//        exclude group:  'cn.leancloud',module:'storage-core'
        exclude group:  'androidx.core',module: 'core'
    }
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'com.alibaba:fastjson:1.1.71.android'
    implementation 'org.ligboy.retrofit2:converter-fastjson-android:2.1.0'

解決之道:項目發生了重複依賴。通過項目的依賴分析和exclude 某一部分的包。來解決這個問題。

對於我自己的項目解決

其實就是加了: exclude group: ‘androidx.core’,module: ‘core’ 這句話。

這句話的意思是,除去某一個組下面的模塊。

那我是怎麼找到要除掉這個模塊的呢?

gradlew :app(要分析的模塊名字):dependencies

gradlew :app:dependencies

從這裏,裏面看
在這裏插入圖片描述
通過對於幾個模塊exclude進行排除驗證,發現是androidx.core這個有問題。然後把它取消依賴即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章