Error : duplicate files during packaging of APK

Error : duplicate files during packaging of APK

我尝试在 Android Studio 上 运行 android eclipse。

我在网上尝试了很多解决方案。

但是还是出了点问题

Error:duplicate files during packaging of APK /home/sam/pst-adnew/panstage/build/outputs/apk/panstage-debug-unaligned.apk
 Path in archive: lib/armeabi-v7a/libmp3lame.so
 Origin 1: /home/sam/pst-adnew/panstage/build/intermediates/exploded-aar/pst-adnew/panstage_local_library/unspecified/jni/armeabi-v7a/libmp3lame.so
 Origin 2: /home/sam/pst-adnew/panstage/build/intermediates/ndk/debug/lib/armeabi-v7a/libmp3lame.so
You can ignore those files in your build.gradle:
 android {
   packagingOptions {
     exclude 'lib/armeabi-v7a/libmp3lame.so'
   }
 }
Error:Execution failed for task ':panstage:packageDebug'.
> Duplicate files copied in APK lib/armeabi-v7a/libmp3lame.so
   File 1: /home/sam/pst-adnew/panstage/build/intermediates/exploded-aar/pst-adnew/panstage_local_library/unspecified/jni/armeabi-v7a/libmp3lame.so
   File 2: /home/sam/pst-adnew/panstage/build/intermediates/exploded-aar/pst-adnew/panstage_local_library/unspecified/jni/armeabi-v7a/libmp3lame.so

我正在使用 NDK android studio..

请帮帮我

我也试过解决方法

packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }

但它不再起作用了。请帮助我:(

PackagingOption 部分中也包括 exclude 'lib/armeabi-v7a/libmp3lame.so'

packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        exclude 'lib/armeabi-v7a/libmp3lame.so'

    }

如果有重复的库 (*.so) 文件,排除选项将无济于事,因为我们无法完全排除本机二进制文件。 packagingOptions 中还有一个选项。是'pickFirst'。我们可以避免重复文件错误并包含编译器遇到的第一个文件。

packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
        pickFirst 'lib/armeabi-v7a/libmp3lame.so'

    }

我遇到了类似的问题,原因是一个模块在长 gradle 文件中包含了两次,很难注意到。

.
.
.
compile project(path: ':common', configuration: 'debug')
.
.
.
compile project(path: ':common')
.
.
.

所以一次是在调试文件夹中添加文件,第二次是在发布文件夹中。

捕获后,我删除了第二行,因为我们需要调试版本中的所有内容。错误消失了。