I am trying to compile an Android project using Ant so that it works with a build machine and I am having issues. I have five projects total: three are just java library projects and the other two are actual Android projects. Only one project is actually compiled and installed but it pulls from the other projects in order to compile.
I have tried using the android update project --name <name> --target <target> --path <path>
to generate my build.xml file. It generates the build.xml just fine but when I go to run it, it can't correctly include my other projects as dependencies.
I then tried to export the build.xml file using Eclipse and that will correctly include the dependencies but it won't generate my R.java files.
I would prefer the second approach because Eclipse has already taken care of my dependency settings, but is there something I can add to the build.xml file that will generate my R.java file correctly?
I ended up figuring this out. What I ended up doing is use the Eclipse export tool to export an ant build script for the three Java library projects. I then created a file called build-custom.xml which contains additional targets for copying the jars.
Next, I used the android update lib-project command on the Android library project to generate the build.xml for that project (as specified in http://developer.android.com/tools/projects/projects-cmdline.html). In order to include the Java library projects in the build, you have to copy them to the libs folder in the Android project. So I created a build file called custom_rules.xml in the Android library project that copys the jars into the lib folder. IMPORTANT: Also write a rule that removes the jars when done otherwise you will get Davlik Error 1 when you try and run in Eclipse.
You may or may not have an Android library project but the steps are pretty much the same for the main project as the library project. Just use the android update project command and then create a custom_rules.xml to copy the appropriate jars.
Edit:
After I used Eclipse to generate the build scripts for the basic Java library projects, I created a common.xml ant build file. This file basically looks like this:
Then in the Android-Sub-Project, I added a custom_rules.xml file that contained the following:
I then created a main build.xml in the project root that includes and runs all the other sub build.xml files:
Hope this helps!