Flutter插件More than one file报错

Flutter Plugin "More than one file" 编译报错

报错内容如下

:app:mergeDebugJavaResource:
More than one file was found with OS independent path 'org/bouncycastle/x509/CertPathReviewerMessages_de.properties'.

报错截图.png

报错原因:

同时引入这两个库时, 有文件冲突, 冲突文件如上图所示

implementation(name: "shaobingSdk-2.0.4-debug", ext: "aar")
implementation 'org.bouncycastle:bcpkix-jdk15to18:1.68'

查找并确认具体重复文件位置:


shaobingSdk

bcpkix-jdk

解决方案

在app目录下的build.gradle添加配置,

android {
    packagingOptions {
        pickFirst 'org/bouncycastle/x509/CertPathReviewerMessages_de.properties'
        pickFirst 'org/bouncycastle/x509/CertPathReviewerMessages.properties'
    }
}
踩坑注意:

因为是flutter plugin, 我在plugin下的build.gradle添加如上配置是不生效的, 必须在主工程内添加才有用!!! 必须在主工程内添加才有用!!! 必须在主工程内添加才有用!!!

你可能感兴趣的:(Flutter插件More than one file报错)