Command line "Android update sdk" on headless Linux

Solution 1:

You can use the --no-ui option:

android update sdk --no-ui

If you'd like to automate it, you could accept all licenses by using the expect tool with this hack (the --accept-license option is currently not fully integrated in the android tool):

expect -c '
set timeout -1;
spawn android - update sdk --no-ui;
expect {
    "Do you accept the license" { exp_send "y\r" ; exp_continue }
    eof
}
'

Solution 2:

Updating Android SDK headless and automatically is described in Stack Overflow question Is there a way to automate the Android SDK installation?.

Solution 3:

I just ran into the same problem. I found a workaround though.

The first one is a cop-out: Download the platforms on a headed system and simply copy the platform subdirectories into your Android sdk/platforms directory.

If, like me, you don't have immediate access to another headed Android development environment, you can go to Google's SDK archives and download one of the other SDK's that included the platforms. This way means that you can only develop for Android 1.1 and 1.5 though.

The download to get for Linux systems is their Android 1.5 r3. Of course, Google's SDK download pages aren't Lynx-friendly, so I had to get the direct link from another GUI system.

wget http://dl.google.com/android/archives/android-sdk-linux_x86-1.5_r3.zip

Then it's simply a matter of unzipping the archive, and moving the platform subdirectories to your newer SDK platform directory.

android create avd -t 3 -p path/to/avd/dir -n "name"

This creates an AVD for the 1.5 platform with your specified name and directory. Note that the avd directory shouldn't exist. If you want to overwrite, add --force to the command.

Getting this far has a platform installed and creates an AVD. Unfortunately, trying to build failed at this point for me, because I run a 64-bit server, and Google only releases 32-bit tools.

I found a solution for this in the accepted answer of this Stack Overflow question and used sudo apt-get install ia32-libs to enable the ability to run the 32-bit tools.

Then you should be able to use the android tool on the CLI to either convert an Eclipse project (for 1.5 or lower) to have an Ant build system, or you can have it create a new project for you to start working on.