views:

1267

answers:

1

I downloaded the most recent version of Android for linux (android-sdk_r05-linux_86.tgz). I was trying to use the the Android Ant task(s) for packaging, building, and deploying my code. I should mention that I'm running AMD64, but have the 32-bit libraries installed. The Android Ant tasks are all broken.

First, the start-emulator task never gets the emulator running. It does get past starting adb, but then just sits there.

Second, the SDK is missing the aapt binary in the tools directory. So, the example notepad sample application will not even package correctly. java.lang.IllegalStateException: Can't find aapt inside the sdk at /home/user/bin/android-sdk-linux_86 at com.googlecode.autoandroid.lib.AndroidTools.locateTool(AndroidTools.java:116) at com.googlecode.autoandroid.lib.AndroidTools.startTool(AndroidTools.java:103) at com.googlecode.autoandroid.lib.AndroidTools.startTool(AndroidTools.java:91) at com.googlecode.autoandroid.lib.UnixAndroidTools.aapt(UnixAndroidTools.java:9)

I have all the dependencies configured for Android. I can run it from the command line just fine.

I assume the Ant code is out of sync with the recent SDK updates. Can anyone shed some light on this problem? At this point, I'm considering writing my own Python scripts to interact with the Android SDK. Ugh.

+2  A: 

I have written three books all using the Android Ant build scripts. Trust me, they work.

First, the start-emulator task never gets the emulator running. It does get past starting adb, but then just sits there.

Run the android command and launch the emulator from AVD Manager window that appears. AFAIK, there is no start-emulator task in Ant -- in fact, I'm not aware that there ever has been one.

Second, the SDK is missing the aapt binary in the tools directory.

If you are looking in $ANDROID_HOME/tools/ (where $ANDROID_HOME is where you unpacked the SDK), you aren't supposed to find aapt there. That directory is for tools that directly support all API levels. API-level-specific tools, like aapt, will reside in $ANDROID_HOME/platforms/$SDK/tools/ (where $SDK is the name of some Android version, like android-2.1).

If you do not have anything in $ANDROID_HOME/platforms/, please follow step 4 of the installation instructions.

CommonsWare
1) I see a start-emulator task in the notepad example and it doesn't seem to work (see subversion):<android:start-emulator only-if-not-running="true"> <arg line="-skin 320x480 -no-boot-anim"/></android:start-emulator>2) The Android Ant tasks get confused with the new directory structure. I now get a "BUILD FAILEDjava.lang.IllegalStateException: Can't find apkbuilder inside the sdk at /home/mike/bin/android-sdk-linux_86/platforms/android-7/"with env:$ echo $ANDROID_HOME /home/user/bin/android-sdk-linux_86/platforms/android-7/$ echo $ANDROID_SDK /home/user/bin/android-sdk-linux_86
mike boldischar
1) Yeah, that's out of date. Wish these docs were kept in sync. Don't use any Ant script you see on there -- use `android create project` or `android update project` to create a proper `build.xml` file. 2) `$ANDROID_HOME` should be `/home/user/bin/android-sdk-linux_86`. My comment about `aapt` was aimed at *you* manually looking for the tool. Modern Ant scripts will find the right `aapt` based on what platform you are targeting.
CommonsWare
I'm having a lot of trouble finding documentation on customizing the build script generated by "android create project". I need to control what to compile and how it gets packaged. The "setup" task is too generic for my purposes.
mike boldischar
There is no documentation, other than the scripts (and associated Java classes) themselves, AFAIK. If you have been working with Android for a long time, knock yourself out. Otherwise, until you're pretty good with Android, I would leave the Ant scripts as is and work within their constraints. Or, switch to Maven. Or, use Eclipse. The build process for an Android app only vaguely resembles the build process for a Java desktop app, servlet, WAR, or whatever. The build tools work great with the current structure and may or may not work with any other structure.
CommonsWare
I solved the problem myself by tweaking properties in the android_rules.xml file. See the following article:http://www.disgruntledrats.com/?p=27
mike boldischar