0

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.

1 Answer 1

0

I eventually discovered what was causing the problem, although not necessarily why.

In ant.properties,

source.dir=/home/chris/git/MyApp/MyApp

should have been

source.dir=/home/chris/git/MyApp/MyApp/src

I only created ant.properties because the project is under git control and I assumed I needed specify where the input is as it's not in the normal place (within the workspace). It turns out I didn't need to do this as the build is smart enough to work it out from other properties.

I've provided this just in case someone else runs into the same problem.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.