With the ADT plug-in installed, the following builders are active for an Android project:
- Android Resource Manager
- Android Pre Compiler
- Java Builder
- Android Package Builder
Looking at the output directory, the following artifacts are created:
- resources.ap_ (just an APK/ZIP with resources and no code)
- gen/R.java (autogenerated list of resources)
- .class files with java bytecode
- classes.dex
- ${project-name}.apk
For my project, I autogenerate several code artifacts and in general need tighter control of the build process. At first, I figured that the Resource Manager was responsible for creating resources.ap_, the precompiler created R.java, java builder did the obvious, and then the Android Package Builder created classes.dex, then combined classes.dex and resources.ap_ to create the APK file.
I disabled the first two steps and created a custom pre-builder that laid down a copy of resources.ap_, figuring this would be equivalent. No such luck.
Unfortunately, the final Android Package Builder seems to slurp the resources directly from res/ and ignores my resources.ap_. In fact, the first two build steps don’t seem to do much other than generate R.java.
This is where it gets really problematic. If I disable the final build step and lay down my own APK file (with the exact same name), I get the following error:
[2011-02-27 20:25:28 - android-premium] ------------------------------
[2011-02-27 20:25:28 - android-premium] Android Launch!
[2011-02-27 20:25:28 - android-premium] adb is running normally.
[2011-02-27 20:25:28 - android-premium] Could not find android-premium.apk!
So I’m stuck: with the Android Package Builder (which has no discernable configuration), I have to supply individual ./res/ files. Without it, I can’t get the project to launch on the device (not from Eclipse).
Anyone have any better ideas / experience in this space?
Regarding Ant scripts, the following is my all-in-one template of the Ant steps for building an Android app (this might be useful to others trying to translate the Eclipse build to Ant as it is much simpler and more transparent than the opaque version autogenerated with the android tools):
What I am looking for is to be able to use all or fragments of this Ant build script, but still have the Eclipse integration for launching and debugging the app.