Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art

Preparing the development environment.

Author: Luis Vitorio Cargnini
Published? false
FormatLanguage: WikiFormat

Problem:

Preparing the development environment.

Solution:

How to install the SDK and the NDK, also how to configure the Eclipse to start developing for Android.

Discussion:

Well, first things first - if you are here is because or you are reading compulsively the text or just jumped here to start. Well if can gave you one device, you can start here but READ the book, you need to know how to code, doesn't matter if you have the tools and know how to use them, but don't have any idea on how to code.

So let's start, the first step is download all the tools you will need, gracefully they are freely available and this url http://developer.android.com/ will be your friend for as long you been developing for Android.

So point your browser to http://developer.android.com/sdk/index.html, and download the SDK according with your OS. In my case I'll be using the Mac OS X. So I downloaded the MAC SDK android-sdk_r06-mac_86.zip, unzip it and put in any directory I wanted. For the sake of organization in general I store all my projects into ~/workspace, including tools.

So following the directions from the developers' site let's start.

1. Prepare your development computer

Read the System Requirements document and make sure that your development computer meets the hardware and software requirements for the Android SDK. Install any additional software needed before downloading the Android SDK. In particular, you may need to install the JDK (version 5 or 6 required) and Eclipse (version 3.4 or 3.5, needed only if you want develop using the ADT Plugin).

Well I'll would suggest goes with the latest version of Java JDK 6, is the one I'm using, the Eclipse can be found here: http://www.eclipse.org/.

2. Download and install the SDK starter package

Select a starter package from the table at the top of this page and download it to your development computer. To install the SDK, simply unpack the starter package to a safe location and then add the location to your PATH.

In Mac (Linux also will be the same), add a environment Variable to stack the PATH, in my case I add additional stuff into the .bash_profile like this:

alias ls="ls -G"
export ANDROID_SDK=$HOME/workspace/android-sdk-mac_86
export DEPOT_TOOLS=$HOME/workspace/depot_tools
#export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin:/usr/texbin:$ANDROID_SDK/tools:$DEPOT_TOOLS
#Android Source code
export PATH=$PATH:~/bin:$ANDROID_SDK/tools:$DEPOT_TOOLS 

# bash-completion
if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

My alias command is to ensure I get ls to output in color mode on my Mac shell. Also I use MacPorts, that is why I have the bash_completion block in the end as well the additional paths in the PATH.

3. Install the ADT Plugin for Eclipse

If you are developing in Eclipse, set up a remote update site at https://dl-ssl.google.com/android/eclipse/. Install the Android Development Tools (ADT) Plugin, restart Eclipse, and set the "Android" preferences in Eclipse to point to the SDK install location. For detailed instructions, see ADT Plugin for Eclipse.

This part is Eclipse specific, but there is no mystery on that.

4. Add Android platforms and other components to your SDK

Use the Android SDK and AVD Manager, included in the SDK starter package, to add one or more Android platforms (for example, Android 1.6 or Android 2.0) and other components to your SDK. To launch the Android SDK and AVD Manager on Windows, execute SDK Setup.exe, at the root of the SDK directory. On Mac OS X or Linux, execute the android tool in the <sdk>/tools/ folder. For detailed instructions, see Adding SDK Components.

In this particular case if you did everything right type android in mac command-line and ... SHAZAM the magic happens.

Now there is another DK, you can install it if you want to create high performance application. The NDK is basic one old friend of Java called Java Native Interface (JNI). For this you will need NDK, it can be found here at http://developer.android.com/sdk/ndk/index.html

To install NDK download it and install pretty much as the SDK, preferably in the same root directory, this way you keep your thing organized.

So with the NDK you can create code in C/C++ that will run natively over the microprocessor, so providing an outstanding performance, as well if you have your own device you can provide a library to access this hardware, trough a Java application without disclosure the hardware details if you want (in my opinion disclosure the hardware details or not is not a big problem in some way this information will be found or surrounded is just a matter of time). But the point is you can create video players that are using systems like H.264 decoders embedded into the core of the microprocessor providing a great performance, without having to code in C/C++ entirely, only for the decoder creating the necessary function for your video player and keep using the Java API provided by Android.

See Also:

http://developer.android.com/, http://www.eclipse.org/, http://developer.android.com/sdk/ndk/, http://developer.android.com/sdk/

Download:

The source code for this project can be downloaded from http://developer.android.com/.
No records found.