Home

Awesome

Examples of using Hunter package manager to build and run Android application.

Requirements

Android NDK

Go to download page and choose NDK for your platform. E.g. Mac OS X:

> wget http://dl.google.com/android/ndk/android-ndk-r10e-darwin-x86_64.bin
> chmod +x android-ndk-r10e-darwin-x86_64.bin
> ./android-ndk-r10e-darwin-x86_64.bin

Now save location of NDK directory so it can be found in toolchain:

> export ANDROID_NDK_r10e="`pwd`/android-ndk-r10e"

Verify correctness:

> ls "${ANDROID_NDK_r10e}/README.txt"
/.../android-ndk-r10e/README.txt

Note that there is no need to download Android SDK manually since it will be downloaded by Hunter.

Android CMake toolchain

Clone Polly collection of toolchains and add <polly>/bin/build.py script to PATH:

> git clone https://github.com/ruslo/polly
> export PATH="`pwd`/polly/bin":$PATH
> which build.py
/.../polly/bin/build.py

Android tools

Every example will print path to the android, emulator and adb tools:

Path to `android`: /.../Install/android-sdk/tools/android
Path to `emulator`: /.../Install/android-sdk/tools/emulator
Path to `adb`: /.../Install/android-sdk/platform-tools/adb

You need to use this tools to create/start emulator. If no real or virtual device started you will see this message while building example:

Added file /.../_builds/android-ndk-r10e-api-21-x86/apk/build.xml
Added file /.../_builds/android-ndk-r10e-api-21-x86/apk/proguard-project.txt
/.../Install/android-sdk/platform-tools/adb uninstall org.pixellight.test
- waiting for device -

Create device

Choose device name from the list. E.g Nexus 6:

> /.../Install/android-sdk/tools/android list device | grep 'Nexus 6'
id: 8 or "Nexus 6"
    Name: Nexus 6

Choose target and skin:

> /.../Install/android-sdk/tools/android list target
Available Android targets:
----------
id: 1 or "android-21"
     Name: Android 5.0.1
     Type: Platform
     API level: 21
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : default/x86
...

Create virtual device:

> /.../Install/android-sdk/tools/android create avd --name "Nexus_6_API_21_WXGA720" --skin WXGA720 --target "android-21"

Now you can find it in list of available devices:

> /.../Install/android-sdk/tools/android list avd
Available Android Virtual Devices:
    Name: Nexus_6_API_21_WXGA720
    Path: /.../.android/avd/Nexus_6_API_21_WXGA720.avd
  Target: Android 5.0.1 (API level 21)
 Tag/ABI: default/x86
    Skin: wxga720

Let's run it:

> /.../Install/android-sdk/tools/emulator -avd Nexus_6_API_21_WXGA720

If you need sdcard for testing:

> /.../Install/android-sdk/tools/mksdcard 512M "`pwd`/android-sdcard"
> /.../Install/android-sdk/tools/emulator -sdcard "`pwd`/android-sdcard" -avd Nexus_6_API_21_WXGA720

Choosing toolchain

API version

Take a look at this wiki to pick the version you need. E.g. if your device using Android 4.4 you need API level <= 19, for instance android-ndk-r10e-api-16-*.

CPU architecture

Run next command to determine CPU architecture of emulator:

> /.../Install/android-sdk/platform-tools/adb -e shell getprop ro.product.cpu.abi
x86

And this one for device:

> /.../Install/android-sdk/platform-tools/adb -d shell getprop ro.product.cpu.abi
armeabi-v7a

Logging

You can use adb to monitor logging messages:

> /.../Install/android-sdk/platform-tools/adb shell logcat

Examples

Links