Skip to content
Run Android application using CMake and Hunter package manager
C++ QML CMake Scilab
Branch: master
Clone or download
Latest commit 8dcc144 Dec 25, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
00-console Add test with spaces Jun 19, 2015
01-load-libraries Update README.md Dec 23, 2016
02-console-boost-filesystem Update README.md Jun 16, 2015
03-console-boost-iostreams
04-console-opencv
05-qt-hellogl2 Update README.md Dec 24, 2016
06-qt-hellogl2-launch
07-mousearea-qml Update README Dec 24, 2016
08-declarative-camera Fix Debug launch Dec 24, 2016
09-vc-mdd-debug Use message(STATUS ...) Aug 2, 2016
cmake Update HunterGate Aug 1, 2016
.gitignore
LICENSE Update LICENSE Jun 1, 2015
README.md Update README.md Oct 17, 2015
common.cmake Update Hunter Dec 25, 2016

README.md

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

You can’t perform that action at this time.