16

I use Android Studio and I have several libraries that I use there.

I have:

android-query-full.0.25.10.jar
gson-2.2.4-sources.jar
slide-menu.jar

I have defined in the build.gradle file to compile the entire libs directory like this:

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile fileTree(dir: 'libs', include: '*.jar')
}

All these working great.

Now I want to add another library "PullToRefresh" I have packaged the Res and Src folders to a single jar file with the source code from eclipse (as I did with SlideMenu.jar) and added the newly created jar as a library to my project next to all others.

when I try to build my project I get the following error from gradle:

Gradle: : duplicate files during packaging of APK C:\Code\TestProject\Test\build\apk\Endilo-debug-unaligned.apk
Gradle: Execution failed for task ':Endilo:packageDebug'.
> Duplicate files copied in APK res/values/attrs.xml
    File 1: C:\Code\TestProject\Test\libs\PullToRefresh.jar
    File 2: C:\Code\TestProject\Test\libs\PullToRefresh.jar

This is very weird as I get duplicates from the same jar file.. what is happening here!?

Kohei TAMURA
  • 4,970
  • 7
  • 25
  • 49
Mortalus
  • 10,574
  • 11
  • 67
  • 117
  • possible duplicate of [Android Gradle plugin 0.7.0: "duplicate files during packaging of APK"](http://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk) – mimming Aug 06 '14 at 22:18
  • @Mortalus : Hello have u find out the solution? – Huy Tower Aug 25 '14 at 09:57
  • It was a bug in the version of gradle .. The upgrade to the layest gradle solved it for me @alex tran – Mortalus Aug 25 '14 at 09:58
  • @Mortalus : oh, I see. I can see u can use 2 or more *.jar file in Android studio correctly while I can not, I always get [Duplicate files during packaging of APK app-debug-unaligned.apk](http://stackoverflow.com/questions/25483410/duplicate-files-during-packaging-of-apk-app-debug-unaligned-apk). I don't know how to fix. You know? – Huy Tower Aug 26 '14 at 02:03

2 Answers2

-1

this happened to me. I export jar from eclipse adt and I got the same error. I solved the problem by opening jar file with WinRAR and remove all folders except two folders: the META-INF and the package folder of classes in my case it was com folder. In my case this happened because of AndroidManifest.xml file inside jar. In your case this is because res/values/attrs.xml but might there are other conflicts and this file is the first conflict.

I hope this helps.

Shaheen
  • 141
  • 2
  • 6
-4

You will find another jar inside the exported jar's bin/ folder; use that one.