More than one file was found with OS independent path 'META-INF/INDEX.LIST'

今天項目新建了netty_lib的module,引入了多個Netty的jar包,但是編譯安裝APK時卻報錯了:More than one file was found with OS independent path 'META-INF/INDEX.LIST'. 後來發現在每個jar下都有相似的結構和文件(如下圖)

後來在網上搜索解決方案,在對應的庫的build.gradle中加入如下代碼:

android{
    ...



    packagingOptions {
        exclude 'META-INF/NOTICE' // will not include NOTICE file
        exclude 'META-INF/LICENSE' // will not include LICENSE file
        exclude 'META-INF/INDEX.LIST' // will not include INDEX.LIST file
    }
}

之後編譯,but,還是報錯。emmmm,繼續搜索解決方案,又在app.gradle中加入上述代碼,編譯還是報錯。最後又加入一句

exclude 'META-INF/*' 後成功解決了。

 

  最終解決方案:在對應的庫的build.gradle中和app.gradle 都加入如下代碼:

packagingOptions {
        exclude 'META-INF/*'
        exclude 'META-INF/NOTICE' // will not include NOTICE file
        exclude 'META-INF/LICENSE' // will not include LICENSE file
        exclude 'META-INF/INDEX.LIST' // will not include INDEX.LIST file
    }

 

============================================================================================

參考博客:https://blog.csdn.net/qq_36317441/article/details/82781222

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