今天項目新建了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