2013-03-30 00:00:00 -0700

VATEDROID - Part 0 - SDKs and NDKs


Setting up an Android Development Environment

A pint of sweat, saves a gallon of blood.

George S. Patton

It’s Dangerous to go alone! Take this!

Android SDK

The Android SDK provides you with the API libraries and developer tools necessary to build, test, and debug apps for Android.

Android NDK

The NDK is a toolset that allows you to implement parts of your app using native code: C and C++.

Why we need it

V8 is written in C++ and we will be compiling to a static library with Android as the platform target. In order to do that, we will need the Android SDK and the NDK. In order for our apps to link against C/C++ static libraries (C Standard Library, STL, V8, etc) we will need the NDK.

The Android Native Development Kit adds an additional layer of complexity for the developer, and the NDK Developers page claims most apps will not receive any benefit (performance or otherwise) from its use. While I normally believe anything I read on the internet, we will be exploring this claim as well

NDK and SDK Setup

Android SDK Setup

  • Download the ADT Bundle

    The Android Dev Portal will make sure you get the correct version for your OS. Otherwise, click the "Download for other Platforms" link.

  • Unzip to a reasonable location

    I typically keep all my sdks in a common folder, like /Users/lorinbeer/dev/sdks

  • add the tools folder to your path, see the last section if you don’t know how

    this will enable us to run the android and adb tools from the command line without specifying their location

Android NDK Setup

  • Download the NDK Bundle

    the Android Dev Portal will make sure you feel like your doing something wrong by thinking about developing a mobile app in native code. Ignore the intro and download the appropriate package for your system.

  • unzip to a reasonable location

    same as above, after your 15th sdk installation, putting them in a common folder will begin to look like an attractive option for keeping things organized

  • add the root folder to your path

    this will enable us to run the ndk tool from the command line without specifying its location

Adding Directories to your PATH

In Unix-like Environments

The path environment variable on unix-like environments is a colon delimited string

Method 1:

export PATH
  • $ export PATH=$PATH:/path/to/my/dir
  • $ echo $PATH

where /path/to/my/dir is the absolute path to the directory you wish to add to the PATH

Note: the modified PATH will only exist in this shell window's environment, and changes will be lost when it is closed

Method 2:

add an entry to the personal initialization file (.bash_profile, .bashrc or .profile) in your home directory

open one of the above initialization files with your favoured editor

  • $ vim .bash_profile or $ nano .bash_profile
  • add an entry to the bottom of the file
  • PATH=$PATH:/path/to/my/dir where /path/to/my/dir is the absolute path to the directory you wish to add to the PATH
  • save the file
  • restart the shell

Note: method 2 insures that these directories are always searched when executing commands whenever you open up a new shell window. On OS X, I set my PATH environment variable in /Users/myusername/.profile

On Windows

the windows path is a semicolon delimited string:
C:\Program Files;C:\WINDOWS;C:\WINDOWS\System32

  • Select System from the control panel or right click My Computer and select properties
  • Select the Advanced System Settings tab
  • Select the Environment Variables button
  • add ;/path/to/my/dir to the path variable using a tiny edit box that hasn't changed since windows 3.11

That’s a Wrap

We should have our Android development environment all set up, and ready to compile V8. Stay tuned for Part 1: Compiling V8 for Android!


comments powered by Disqus