Android: Difference between revisions

From KDE Community Wiki
No edit summary
Line 12: Line 12:
#* libgcc, zlib, libc
#* libgcc, zlib, libc
# installing on Debian based system:
# installing on Debian based system:
#* dpkg --add-architecture i386
#* <code>dpkg --add-architecture i386</code>
#* apt-get install zlib1g:i386 libgcc1:i386 libc6:i386
#* <code>apt-get install zlib1g:i386 libgcc1:i386 libc6:i386</code>
# Extra-CMake-Modules
# Extra-CMake-Modules
#* we require at least version >= 5.15 due to https://git.reviewboard.kde.org/r/125183
#* we require at least version >= 5.15 due to https://git.reviewboard.kde.org/r/125183

Revision as of 18:30, 12 September 2015

KDE on Android

Android is currently the mobile platform regarding market share and provided applications. Hence, it is a platform well suited to increase the availability and usage of applications by the KDE community. In the following, we give an overview of the technical steps required to setup a build system for cross-compiling a Qt5/KF5 based application, the necessary steps to compile and deploy it, and a reference list on the porting steps already done.

Tutorial for Building Applications on Android For building Qt applications on Android, some extra steps are required in comparison to building directly on Linux. The following instruction expects that KF5/Qt5 based applications can already be build and all necessary tools are installed (gcc, cmake, git,...). The main idea for the setup is that we use precompiled Qt libraries (see NDK and SDK), which are built for the ARM-based Android platform. All building is then done according to these libraries while for the build-process itself we use the tools from the Linux system (in the following called "host system"; while the Android device is called "target system"). The additional tools mostly are the Java Development Kit and according tools for building Java applications.

Prerequisites / Setup of Cross-Compiling Build System

At first we prepare your system with all necessay packages to build your application for Android. For this tutorial we assume that everything is done in the folder /opt/android/ (you can adapt the tutorial accordingly when using another folder).

  1. Some 32 bit system libraries are required:
    • libgcc, zlib, libc
  2. installing on Debian based system:
    • dpkg --add-architecture i386
    • apt-get install zlib1g:i386 libgcc1:i386 libc6:i386
  3. Extra-CMake-Modules
  4. Android SDK
    • Download: http://developer.android.com/sdk/index.html to /opt/android/
    • Unpack, run "tools/android update sdk" and select the following packages:
      • Android SDK Tools (24.3.4)
      • Android SDK Platform-tools (23.0.1)
      • Android SDK Build-tools (22.0.1)
      • Android 5.1.1 (API 22): SDK Platform (only "SDK Platform" needed, i.e. no docs, samples or sources)
    • result: now the SDK should be installed in /opt/android/android-sdk-linux
  5. Android NDK
  6. Qt with support for Android devices
    • Download the Qt 5.5.0 for Android: https://www.qt.io/download-open-source/#section-2 (32-bit or 64-bit as it fits your host system; usually 64-bit)
    • Variant 1: Offline Installers ("Skip" can be used without problem when asked to register an account)
    • Variant 2: Online installer ("Skip" can be used without problem when asked to register an account)
    • install the following components to /opt/android/Qt5.5.0:
      • Android armv7
      • Qt Creator 3.4.2 (cannot be disabled, some of its tools are used from other parts)
      • Recommended components:
        • Qt Quick Controls
        • Qt Location
        • Qt Script
        • Optional components (there might be KDE software using it):
        • Qt WebEngine
        • Qt Canvas 3D
        • Qt3D
        • Qt Quick 1
  7. Install the following software packages on your host system from your package manager (if not yet installed):
    • CMake: >= 2.8.6
    • Java Development Kit 7 (openjdk-7-jdk)
    • Ant

Setup Build Environment

The build environment is the name for the shell in that the application is build. The shell is prepared by exporting a series of environment variables that then are picked up by the build scripts.

export ADIR=/opt/android
export ANDROID_NDK=$ADIR/android-ndk-r10e
export ANDROID_SDK_ROOT=$ADIR/android-sdk-linux
export Qt5_android=$ADIR/Qt5.5.0/5.5/android_armv7/
export ANDROID_API_VERSION=android-22
export PATH=$ADIR/android-sdk-linux/platform-tools/:$PATH

# adapt the following path to your ant installation
export ANT=/usr/bin/ant

# adapt the following path to your openjdk location, eg:
# openSUSE:/usr/lib64/jvm/java
# Debian: /usr/lib/jvm/java-7-openjdk-amd64
# Use "jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));'" to find the dir if needed
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk/

Some notes:

  • /opt/android should be replaced with the custom build folder selected by you
  • Java platform 7 is needed (both JRE and JDK). One can select the Java platform versions e.g. with update-alternatives --config java and update-alternatives --config javac

Build with KDESRC-BUILD

TODO

Packaging and Deployment of APKs

TODO

Further References

References:

Application specific build instructions:

Blog posts about building for Android (careful: instructions may be outdated)