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下都有相似的结构和文件(如下图)More than one file was found with OS independent path 'META-INF/INDEX.LIST'_第1张图片

后来在网上搜索解决方案,在对应的库的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

你可能感兴趣的:(android实用)