The Android documentation recommends using Eclipse for development, but this is sluggish on my laptop, and feels cluttered on compact screens. A stated alternative is to use Ant, but this is also unnecessary as the build commands it invokes can be easily extracted and executed manually. This suits my preference for a minimalistic or practically non-existent IDE, especially on laptops, as well as my distaste for editing XML. As a bonus, on Ubuntu, I install one package:
$ sudo apt-get install sun-java6-jdk
along with the Android SDK and I'm ready to develop for Android. In contrast, the Ant package has several dependencies, and the required version of Eclipse is newer than the currently available Ubuntu package.
Here are the details:
$ SDKDIR=~/android-sdk-linux_x86-1.0_r2 # Where I extracted the SDK.
$ activitycreator -o somepath some.project.name
$ cd somepath
At this point Ant can build the project, but masochists like me will prefer to shun Ant and run the underlying commands themselves. The following command generates R.java from the resources:
$ aapt p -m -J src -M AndroidManifest.xml -S res -I $SDKDIR/android.jar
Next, the source is compiled to .class files. This is why we need the JDK:
$ mkdir bin/classes
$ javac -encoding ascii -target 1.5 -d bin/classes \
-bootclasspath $SDKDIR/android.jar src/some/project/*
# When libs exist, append -classpath=libs/*.jar
These files contain instructions for the JVM. They are converted to Dalvik bytecode via:
$ dx --dex --output=bin/classes.dex bin/classes # If libs exist, append libs/*.jar
The resources and assets are packaged:
$ aapt p -f -M AndroidManifest.xml -S res -I $SDKDIR/android.jar -F bin/projectname.ap_
# When assets exist, add -A assets
This package is itself packaged with the Dalvik bytecode to make the final product:
$ apkbuilder bin/something.apk -z bin/projectname.ap_ -f bin/classes.dex -rf src -rj libs
# Use -u for unsigned builds.
Now if I could only roll my own Dalvik compiler for a language I like, I could avoid the Java SDK, as well as Java itself.