Building PokerTH for Android
Requirements
- QT 5 for android: (
 - Android NDK toolset r13b (
 - JDK v7+
 - ant 1.8+
 
CMOSS
CMOSS is a set of libraries built for android.
To get CMOSS and build them:
$ git clone
$ cd cmoss/build-droid/
$ ./build-all.sh [NDK_DIRECTORY] ## (eg: ./build-all.sh ~/android/android-ndk-r13b)
Remarks:
- This process could lauch some errors. It's possible one has to manually modify some variables in build-all.sh. Good luck ;)
 - Important note: ndk version should be r13b as the cmoss libs build best with it.
 - If don't have wine installed ( there are two options:
 - Steps:
 - Install it ;)
 - Get protoc for windows: and extract it in PokerTH source directory. Then, rename protoc-2.4.1.exe to protoc.exe. Note that build for protobuf shall fail, but it's not a big deal. Just ignore it.
 - Some steps...
 - Check your protoc version ($ protoc --version)
 - Edit build-all.sh and replace [export PROTOBUF_VERSION="2.4.1"] for [export PROTOBUF_VERSION="your protoc version"]
 - Edit build-protobuf.sh and replace [--with-protoc=`wine ${TOPDIR}/protoc-2.4.1.exe`] for [--with-protoc=/usr/bin/protoc] in ./configure command
 - Edit pokerth-protocol.pro and remove "wine" from android entry
 - Depending on your device, might be usefull to edit build-all.sh and replace:
 - [export ARM_TARGET="armv5"] for [export ARM_TARGET="armv7"]. Make sure your android device is able to run with armv-7 architecture before switch. If you are not sure, just leave "armv5". See later note in compilation process (*)
 - [export ANDROID_API_LEVEL="9"] for [export ANDROID_API_LEVEL="<NDK_VERSION>"], where <NDK_VERSION> is your ANDROID NDK version.
 
Get code
Same as version for Linux
Compilation
set ANDROID_NDK_ROOT variable to its directory. E.g.:
$ export ANDROID_NDK_ROOT=~/android/android-ndk-r13b
Run qmake for Android and make. E.g:
$ ~/Qt/Qt5.7.1/5.7/android_armv7/bin/qmake CONFIG+="client gui_800x480" PREFIX+="[CMOSS_DIRECTORY]/bin/droid" -spec android-g++ pokerth.pro
$ make
Once finished, ./libpokerth.so must be created
Remarks:
If Qt for Android is different than 5.7.1, you have to correct some files, replacing [#include "QtGui/5.7.1/..."] for the aproppiate version you donwloaded, in following files:
- ./src/gui/qt/aboutpokerth/aboutpokerthimpl.cpp
 - ./src/gui/qt/gametable/gametableimpl.cpp
 - ./src/gui/qt/startwindow/startwindowimpl.cpp
 
(*) If you modified ARM architecture when compiling CMOSS (from armv5 to armv7), before running qmake and make you have to replace in pokerth_game.pro from:
android{
LIBPATH += $${PREFIX}/lib/armv5
LIB_DIRS = $${PREFIX}/lib/armv5
}
to
android{
LIBPATH += $${PREFIX}/lib/armv7
LIB_DIRS = $${PREFIX}/lib/armv7
}
Get Android SDK
Download " (or newer) and uncompress in any folder
Get SDK:
$ cd tools_r25.2.3-linux/tools
$ ./android
A GUI application will be launched to select tools and versions to be installed. Install, at least:
- From Tools: Android SDK Tools; Android SDK Build-tools; Android SDK Platform-tools
 - Full Android SDK v5.1.1 (API 22) or newer
 
Build APK
First, edit android-libpokerth.so-deployment-settings.json file to set the appropriate SDK location, for instance:
"sdk": "~/android/tools_r25.2.3-linux",
Set JAVA_HOME and append javac to PATH
$ export JAVA_HOME=/usr/lib/jvm/java-8-oracle
$ export PATH=$JAVA_HOME/bin:$PATH
Build APK:
$ make install INSTALL_ROOT=./bin/
$ ~/Qt/Qt5.7.1/5.7/android_armv7/bin/androiddeployqt --input android-libpokerth.so-deployment-settings.json \
--output ./bin --deployment bundled --android-platform android-22 --jdk /usr/lib/jvm/java-8-oracle --ant /usr/bin/ant
APK should be created in ./bin/bin/QtApp-debug.apk
