我尝试在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'
}

但它不再起作用了。请帮帮我:(
答案 0 :(得分:12)
如果存在重复的库(* .so)文件,则排除选项将无济于事,因为我们无法完全排除本机二进制文件。 packagingOptions还有一个选项。这是第一次选择。我们可以避免重复文件错误,并包含编译器遇到的第一个错误。
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'
}
答案 1 :(得分:1)
在 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'
}
答案 2 :(得分:0)
我有一个类似的问题,原因是一个模块被包含在long gradle文件中两次并且很难注意到。
.
.
.
compile project(path: ':common', configuration: 'debug')
.
.
.
compile project(path: ':common')
.
.
.
因此,一旦它在调试文件夹中添加文件,第二次在发布文件夹中添加。
一旦被抓住,我删除了第二行,因为我们需要调试版本中的所有内容。错误消失了。