Setting Up An Android Virtual Machine on Ubuntu

This tutorial will help you set up an Ubuntu Android Virtual Machine.


1) Download the Android SDK for Linux.  Currently, only i386 is available.


2) Extract the downloaded SDK to a folder.  I like to place my binaries in ~/bin  Here is an example:

tar xzf android-sdk_r05-linux_86.tgz
cd android-sdk-linux-86



3) If you have a 64-bit Ubuntu instance, install Java and the 32-bit libraries as follows:

sudo apt-get install ia32-libs
sudo apt-get install sun-java6-bin



4) Edit your ~/.bashrc using favorite editor.  You are going to add the Android tools to your path, so you don’t need to be in the tools directory to run Android commands.  Add the following lines and replace the variables with your personal configuration:

export ANDROID_HOME=<path to the android sdk>
export PATH=${ANDROID_HOME}/tools:${PATH}



5) Reload your .bashrc file by running the following command:

source ~/.bashrc



6) Run the Android SDK and AVD Manager as follows:

android



7) In the Android SDK and AVD Managar, install an Android Package.  A package is basically a set of virtual machine files for a particular version. To do this, select “Available Packages” and select “SDK Platform Android 2.1, API 7, revision 1″ and click the “Install Selected” button.  You could choose a different version, but the remainder of this tutorial assumes you are using Android 2.1.


8 ) A user agreement will come up.  Just agree to it and the Android Package will download and install.


9) Now, it’s time to create a new Virtual Device (basically an Android VM).  Navigate to the “Virtual Devices” panel of the Android SDK and AVD Manager.


10) Click the “New” button to open the “Create new AVD” window.


11) Enter a name for your AVD.  This is important to remember, I will reference it as <avd_name> in the remainder of this tutorial.


12) Choose the Target, “Android 2.1 – API Level 7″


13) The rest of the default values for this screen are okay.  Click the “Create AVD” button to make your new Virtual Device.


14) Close the Android SDK and AVD Manager window.


15) Start your new Virtual Device by running the following command (using the name of the AVD you specified in step 11).

emulator -avd <avd_name>



16) If it starts loading, party a little bit; maybe do a little dance in your chair.


17) If you have an Android package/program you’d like to test (as I do), you need to start an ADB server before you can send the package/program over to the Virtual Device.  Run the following command to start the ADB server:

adb start-server



18) Transfer your Android package/program over to the Virtual Device using the ADB command.  Here is an example:

adb install my-android-program-debug.apk



Uninstalling your program using ADB fails many times.  You need to uninstall your program from within the Virtual Device menu system.  I only had to do this once because it was giving me install errors.

Related Posts

0 Comments

Add Your Comment

You must be logged in to post a comment.