Error: duplicate files when packaging APK

I am trying to run eclipse for Android in Android Studio.

I am trying to find many solutions on the internet.

But something is wrong anyway

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
      

Run codeHide result


I am working with NDK android studio.

Please help me.

I have also tried the solution

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'
    }
      

Run codeHide result


But it doesn't work anymore. Please help me: (

+3


source to share


3 answers


Include exclude 'lib/armeabi-v7a/libmp3lame.so'

as well in the PackagingOption section .



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'

    }

      

0


source


In the case of duplicate library files (* .so), the exclude option will not help, since we cannot completely exclude the original binaries. There is one more option in the package Options. This is "pickFirst". We can avoid the duplicate files error and include the first one that the compiler encounters.



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'

    }

      

+11


source


I had a similar problem and the reason was that the module was included twice in a long gradle file and is hard to notice.

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

      

So as soon as it added the files to the debug folder and the second time in the release folder.

Once I caught it, I removed the second line as we need everything in the debug version. The error is gone.

0


source







All Articles