Saturday, November 22, 2014

Android Studio RC1

To install Android Studio manually:
Windows: (235 MB)
Mac: (234 MB)
Linux: (233 MB)

Saturday, November 15, 2014

How to compile C++ Game for Andorid NDK using Mac Terminal and Ant

This is a walkthrough of building C++ application with Android ndk and ant without using Eclipse IDE

1. Download the latest Android SDK from

and install Java SDK SE from Oracle say jdk-7u71-macosx-x64.dmg
2. Download Android NDK from say

3. Install apache ant

Please take note that for Mac OSX Mavericks, ant is no longer in Mac, just download a binary distribution of Ant from . and unzip/untar it, and add its bin directory to PATH.

4. Use Mac Terminal and add path to the above three installation folders
e.g. export PATH=${PATH}:~/android-sdk-macosx/tools:~/android-sdk-macosx/platform-tools:~/android-ndk-r9d:~/apache-ant-1.9.4/bin

5. Use Terminal command android sdk and android avd to update the sdk (install sdk of minimum of API-15 (Android 4.0.x) and create a new avd)

If you use Intel HAX for fast virt mode in emulator, please set Use Host GPU to on.

6. Download some C++ game source code e.g. here . Just download the Source Code from the book website and extract say
If you want to support multiple platforms add this APP_ABI in HelloDroid/jni/
APP_PLATFORM := android-16
APP_ABI := armeabi armeabi-v7a x86

7. ndk-build
cd ~/Download/HelloDroid
ndk-build clean && ndk-build

list target (assume sdk installed already in step 5 above)
android list target

update project with target 1 (assume target id 1 is already created with API-16 in step 5 above)
android update project -n com.beginndkgamecode.hellodroid -t 1 -p .

list avd (assume "NokiaX" is created in step 5 above)
android list avd

8. start emulator
emulator -avd NokiaX -scale 0.5 &

debug build
ant clean && ant debug

install apk to emulator
ant debug install

(1) use ant uninstall if need to remove
(2) use Control-fn-F12 to rotate the emulator in Mac
(3) the generated apk file is bin/com.beginndkgamecode.hellodroid-debug.apk
(4) add android:icon to AndroidManifest.xml like this to add a default icon.
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name" ...