Wednesday, July 25, 2012

Computer Science-Android Development Environment

Android Development Environment

This is meant to be a quick summary, in setting up an android development environment. There is more thorough documentation provided at However it can be a bit confusing to read through. This is meant to help as a quick reference. Now first to get started we must install the necessary development kits and tools, these include the Eclipse JDT, and the Android NDK and SDK. You can find Eclipse at:
Select Eclipse classic 4.2 for your system whether it be Windows, Linux, or Mac.
Then go to:
Where you can find the android sdk, and here for the ndk

Eclipse is the java environment where you can develop your android application, and the ndk and sdk are development kits for c++ and java respectively. Place the ndk and sdk in a development directory of your choosing. Choose a simple file path as you will need to link to these later on.

Now we have to set up eclipse itself for android development. Open eclipse and select a workspace folder.

Installing the ADT Plugin
Follow the instructions located here in order to set up the ADT Plugin
I’ve summarized the instructions here for convenience:

  1. In eclipse, select Help > Install New Software
  2. Click Add in the top right corner
  3. An add repository window should appear, enter "ADT Plugin" for the name and this as the URL for Location:
  4. click ok, if there is an error try http instead of https
  5. select the available software and click next, and download the tools that you require for the given api levels.
  6. restart eclipse when finished with instillation
This is to tell eclipse where to find the development kits

  1. Select Window > Preferences or Eclipse > Preferences if on Mac OS X
  2. Select Android
  3. Find the SDK Location in the top of this main panel and browse to the SDK directory
  4. Apply, then ok
For the NDK

  1. Select Window -> Preferences -> Android -> NDK or Select Eclipse -> Preferences -> Android -> NDK if on Mac OS X
  2. Then locate the NDK directory through browse

Emulation Wrapper
Now browse to the top level folder of your the android sdk.
cd /android-sdk/tools/
Once here we need to make some changes to the emulator, current as of July 2012 there is an error caused by an audio memory leak in running the android emulator through eclipse. Thus we have to create a wrapper so that eclipse can run the emulator with a reduced risk of crash.

mv emulator emulator.real
vi emulator

Input the following into the text file

exec /Users/lukchristo/eclipse/android-sdk/tools/emulator.real -noaudio -avd AndroidTest

Additional commands can be found here

AVD Command Line Creation
Now to create a Android virtual device we follow the directions here:

./android-sdk-macosx/tools/android list targets
./android-sdk-macosx/tools/android create avd -n MyTestAVD -t 1
Do you wish to create a custom hardware profile [no] no

The AVD devices will be placed in /User/<username>/.android/avd/MyTestAVD

ADB Install and Commands
In the case where you want to install a package onto the emulator, first open the emulator. You can do this from either command line or from eclipse. From the command line run
in order to open the avd
Then once the emulator is open go to
then run the command
./adb install /filepathtopackage/package.apk

./adb push can be used to push a file from your directory to the device being simulated
./adb push foo.txt /sdcard/foo.txt
./adb pull can be used in the opposite manner to push, retrieving a file from the device being simulated

No comments:

Post a Comment