Sunday, October 9, 2011

Installing a specific Android SDK component from terminal on an Amazon ec2 instance

For his Software Project Management class, Professor Riesbeck is having us setup continuous integration servers. Our eventual projects will be using PhoneGap to create Android/iOS apps (Android in my team's case), so my task this weekend has been to figure out a way to set up a CI server (we chose Hudson) on to an Amazon ec2 instance.

I faced several problems while doing this, and one of the big ones was how to get the android sdk over to the amazon server.

The first thing I tried was to cp the monstrosity that is the sdk over to the ec2 instance. Here's the command I used:

sudo cp -r android-sdk-linux_x86/ ec2-user@*********

However, the transfer was taking forever (and I had a WildCats game to go to), so after about 30 minutes of waiting, I ctrl+C'd it. After some googling around, however, I discovered the wget command. I don't know how I've never stumbled across it before, but it's fantastic! All it does is download stuff of the internet from the command line, which is precisely what I needed. Here's how I used it:


Since Amazon's internet is waaay faster than mine, it worked like a charm, and I had the sdk file in a few minutes.

My next problem was that I didn't have any SDK components, and I needed to figure a way to get them without opening the SDK manager GUI, since I was ssh'd into the ec2 instance via terminal. I also wanted to get only the components I needed, because I didn't want to waste a lot of time/bandwidth.
Again, some Googling helped me find the android sdk update command. To use it, navigate to <your_sdk_folder>/tools. The file you need is called 'android'. Run ./android help to find out more about it. To learn more about the sdk update command, learn ./android sdk update help.

Here's what I did to get what I wanted:

    ./android list sdk

This will give you a numbered list of packages available for install. It looks something like this:

    Packages available for installation or update: 35
    1- Documentation for Android SDK, API 13, revision 1
    2- SDK Platform Android 3.2, API 13, revision 1
    3- SDK Platform Android 3.1, API 12, revision 3
    4- SDK Platform Android 3.0, API 11, revision 2
    5- SDK Platform Android 2.3.3, API 10, revision 2
    6- SDK Platform Android 2.3.1, API 9, revision 2 (Obsolete)
    7- SDK Platform Android 2.2, API 8, revision 3
    8- SDK Platform Android 2.1, API 7, revision 3
    9- SDK Platform Android 1.6, API 4, revision 3
   10- SDK Platform Android 1.5, API 3, revision 4
   11- Samples for SDK API 13, revision 1
   12- Samples for SDK API 12, revision 1
   13- Samples for SDK API 11, revision 1
   14- Samples for SDK API 10, revision 1
   15- Samples for SDK API 8, revision 1
   16- Samples for SDK API 7, revision 1
   17- Google APIs by Google Inc., Android API 13, revision 1
   18- Google TV by Google Inc., Android API 12, revision 2
   19- Google APIs by Google Inc., Android API 12, revision 1
   20- Google APIs by Google Inc., Android API 11, revision 1
   21- Google APIs by Google Inc., Android API 10, revision 2
   22- Dual Screen APIs by KYOCERA Corporation, Android API 10, revision 1
   23- EDK 1.1 by Sony Ericsson Mobile Communications AB, Android API 10, revision 1
   24- Google APIs by Google Inc., Android API 9, revision 2
   25- Google APIs by Google Inc., Android API 8, revision 2
   26- Dual Screen APIs by KYOCERA Corporation, Android API 8, revision 1
   27- Real3D by LGE, Android API 8, revision 1
   28- GALAXY Tab by Samsung Electronics., Android API 8, revision 1
   29- Google APIs by Google Inc., Android API 7, revision 1
   30- Google APIs by Google Inc., Android API 4, revision 2
   31- Google APIs by Google Inc., Android API 3, revision 3
   32- Android Compatibility package, revision 3
   33- Google Admob Ads Sdk package, revision 3
   34- Google Market Licensing package, revision 1
   35- Google Market Billing package, revision 1

Use the numbers on the list to run the update command. For instance, in my case, I needed the Google API's for Android 2.3.3, which depends on the Android 2.3.3 API. To adapt the update commant, this was:

    ./android update sdk -u -n -t 5,21

The -n argument simulates the install, so you don't actually download a few gigabytes of data accidentally. Run the command without -n to do the actual install.
The -u argument suppressed the user interface, so that the GUI didn't show up.
The -t argument was needed for the filter.


Post a Comment

Follow by Email