Skip to content
Mariano Reingart edited this page Aug 13, 2014 · 13 revisions

Android build notes for wxQT

See issue #10 for screenshots and a sample APK. Due the change in plans, the wxWidgets build process was not adapted yet to compile apps for Android, so some manual modifications are need to Makefiles and environment variables.

See announce (in wx-dev google group forum)

First step: tool chain preparation

Download Android Native Development Kit, install and follow the following instructions (change NDK and other paths)

NDK=~/src/android-ndk-r9d
SDK=~/src/android-sdk-linux
export ANDROID_NDK_ROOT=$NDK
$NDK/build/tools/make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.8 --platform=android-9 --install-dir=/tmp/ndk

export PATH=/tmp/ndk/bin:$PATH
export CC=arm-linux-androideabi-gcc  
export CXX=arm-linux-androideabi-g++ 

Also, you'll need to download the:

  • Standalone Android Software Development Kit (SDK), in this case installed in ~/src/android-sdk-linux
  • Qt library that matches your operating system installed package (5.2.1 in this case installed in ~/src/qt, you'll need the android_armv5/ android_armv7/ android_x86/ pre-compiled folders to cross-compile for that architectures)

Second step: build wxWidgets library

Create a build directory (under the wxWidgets folder), configure and make:

cd ~/src/wxWidgets
mkdir bldqt5droid
cd bldqt5droid
../configure --with-qt --enable-debug  --build=x86_64-unknown-linux-gnu --host=arm-linux-androideabi  --disable-compat28 --disable-shared --disable-arttango --enable-image --disable-dragimage --disable-sockets  --with-libtiff=no --without-opengl --disable-baseevtloop --disable-utf8 
make

NOTE: you can see the original customized config script for more information.

Third step: compile wxWidgets sample app

In the controls samples build Makefile, change some settings to build the correct solib:

  • LDFLAGS: add -Wl,-soname,libgsoc2014.so -Wl,--no-undefined -Wl,-z,noexecstack -shared -L ~/src/qt/5.2.1/android_armv5/lib (change ~/src/qt to the path where you installed Qt -not your system libs-, and probably another settings should be adapted too)
  • EXTRALIBS_GUI: remove -lQt5Test, -lQt5OpenGL and -lSM (you could include them, but you'll need to modify the pre-packaged app structure)

Then, compile it and copy it to the gsoc2014 pre-packaged folder (see bellow):

cd samples/controls
make
cp controls ~/gsoc2014/android/libs/armeabi/libgsoc2014.so

Fourth step: create the android package

In the pre-packaged gsoc2014 folder, build the APK:

##make install INSTALL_ROOT=android
##~/qt/5.2.1/android_armv5/bin/androiddeployqt --output android --android-platform android-10
cd android
ant debug

Fifth step: install the android package:

Start the Android SDK emulator (for example, in $SDK/tools/android), and install the APK:

# NOTE: add -r option before package path if it is not already installed:
$SDK/platform-tools/adb -e install bin/QtApp-debug.apk
# check log messages:
$SDK/android-sdk-linux/platform-tools/adb -e logcat

For a customized debug script, see gdb.sh developed for this project.