I've been creating my app .apk using Eclipse export for some while, but I'd now like to build using ant so I can customize the process. Following advice elsewhere, I used the "android create project" command to generate a suitable build.xml file in a temp project (and then modified it).
When I build, it fails with a duplicate file error in the package step:
-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating MyApp-debug-unaligned.apk and signing it with a debug key...
[apkbuilder] Found duplicate file for APK: res/drawable-mdpi/icon.png
[apkbuilder] Origin 1: /home/chris/temp/MyApp/MyApp.ap_
[apkbuilder] Origin 2: /home/chris/git/MyApp/MyApp/res/drawable-mdpi/icon.png
...
/home/chris/android-sdk-linux_x86/tools/ant/build.xml:310: com.android.sdklib.build.DuplicateFileException: Duplicate files at the same path inside the APK
My ant properties are:
source.dir=/home/chris/git/MyApp/MyApp
out.dir=/home/chris/temp/MyApp
It seems to be a collision between the contents of the res directory and the intermediate .ap_ resource package file created during the build. I don't understand why packaging would be including contents from both of these sources, as duplicates would appear to be the inevitable result.
I originally thought the problem was caused by the res subdirs (drawable-hdpi, drawable-ldpi, drawable-mdpi) all containing a file with the same name (icon.png), but I tried naming these differently and the error still occurred. In any case the Eclipse export build handles them without a problem.
This problem appears similar Android aapt duplicate files error when building with ant but in that case the person was creating their own build.xml where I am using the one provided in the android sdk.
Any help will be much appreciated.