Marble/AndroidCompiling: Difference between revisions

From KDE Community Wiki
(marble_maps => marble-maps)
No edit summary
Line 75: Line 75:


First, run the following command:
First, run the following command:
<syntaxhighlight lang="bash">cmake -DCMAKE_TOOLCHAIN_FILE="${Qt5_android_cmake}/toolchain/android.toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -DQT_NO_WEBKIT=TRUE -DQT_NO_PRINTER=TRUE  -DQT_NO_DBUS=TRUE -DCMAKE_INSTALL_PREFIX=. ../sources/
<syntaxhighlight lang="bash">cmake -DCMAKE_TOOLCHAIN_FILE="${Qt5_android_cmake}/toolchain/android.toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -DQT_NO_WEBKIT=TRUE -DQT_NO_PRINTER=TRUE  -DQT_NO_DBUS=TRUE -DCMAKE_INSTALL_PREFIX=../export ../sources/
</syntaxhighlight>
</syntaxhighlight>
This will generate the needed Makefile for compiling. Start the compiling process and generate the APK with the following command:
This will generate the needed Makefile for compiling. Start the build process with the following command:
<syntaxhighlight lang="bash">make install/strip</syntaxhighlight>
<syntaxhighlight lang="bash">make install/strip</syntaxhighlight>


=== Sending the application to your device ===
=== Generating the Android Application Package (APK) ===
After the build successfully finished, the apk will be in the following directory:
After the build successfully finished, the files have been installed to {{Path|1=../export}} or whichever other path you passed in the <code>-DCMAKE_INSTALL_PREFIX</code> option to cmake. Now run the Python script {{Path|1=src/apps/marble-maps/create-apk.py}} to generate the Android package:
<syntaxhighlight lang="bash">cd ~/marble/build/src/apps/marble-maps/bin/</syntaxhighlight> 
<syntaxhighlight lang="bash">~/marble/sources/src/apps/marble-maps/create-apk.py --target MarbleMaps.apk ../export
You can send the compiled application to your connected device with the following command:
</syntaxhighlight>  
<syntaxhighlight lang="bash">adb install -r QtApp-debug.apk</syntaxhighlight>


=== Package Signing ===
The script provides a number of parameters. Typical usage is as follows:
This step is optional and only needed if the package should be published in Google Play. To have the generated {{Path|1=.apk}} signed for a release, place {{Path|1=Marble.keystore}} in {{Path|1=src/apps/marble-maps/}}. During packaging (when running <code>make install/strip</code>, see above) you'll be prompted for the required passwords. {{Path|1=Marble.keystore}} and the passwords are kept private among Marble Android packagers.
* Testing directly on a connected device: <code>create-apk.py --reinstall /path/to/marble/export</code>
* Creating an .apk locally: <code>create-apk.py --target MarbleMaps.apk /path/to/marble/export</code>
* Creating a signed package for release: <code>create-apk.py --target MarbleMaps.apk --keystore /path/to/Marble.keystore /path/to/marble/export</code>. You'll be prompted for the required passwords (unless you pass them using the <code>--storepass</code> option).
 
All parameters of {{Path|1=create-apk.py}} can be shown with its <code>--help</code> switch:
{{Output|1=<nowiki>
usage: create-apk.py [-h] [--target TARGET] [--keystore KEYSTORE]
                    [--storepass STOREPASS] [--release] [--install]
                    [--reinstall]
                    directory
 
Create an Android application package (APK) for Marble Maps
 
positional arguments:
  directory            The directory where the Android build is installed to
 
optional arguments:
  -h, --help            show this help message and exit
  --target TARGET      Target filename (or directory) for the .apk package
  --keystore KEYSTORE  Keystore file for signing the package
  --storepass STOREPASS
                        Keystore password for signing the package
  --release            Build a release package
  --install            Install the package to a connected device
                        (uninstalling it before, if needed)
  --reinstall          Install the package to a connected device (keeping
                        previous data intact, if any)
</nowiki>}}

Revision as of 16:49, 26 July 2015

 
Under Construction
This is a new page, currently under construction!


This page present how to compile Marble for Android, using the Android SDK, Android NDK and Qt for Android, and how to deploy it to your device.

Prerequisites

You will need the following tools:

  1. Android SDK - It can be downloaded from here: http://developer.android.com/sdk/index.html

Note

The SDK contains binary 32 bit tools that are required to create the Marble package. If you're running a 64 bit system, install support for running 32 bit applications.
  1. Android NDK - You can download it from here: https://developer.android.com/ndk/index.html
  2. Qt with support for Android devices. Download the best one for you: https://www.qt.io/download-open-source/#section-2 and install it, but be sure that the Android support is installed too (for example you have to check in to install it in the online installer).
  3. CMake - Usually you should be able to install it from your repository.
  4. Java Development Kit - For example you can install openjdk, usually it should be in your repository.
  5. Ant - This should be available from the repositories too.

Some Android platforms will be needed, you should install them with the Android SDK's package manager. It can be started with:

  1. /path_where_you_installed_the_sdk/tools/android sdk
    

Make sure to install the following platforms:

  1. 10
  2. 11
  3. 16
  4. 18
  5. 19

Getting the Marble Source Code

  1. Start a terminal
  2. We download the source code by cloning the developer repository with the following command:
git clone git://anongit.kde.org/marble ~/marble/sources

After you run the git clone command (shown above), all the Marble source files and considerable resource files will be found in a folder called marble in your home directory.

Getting the CMake toolchain for Android

First, you should change your working directory to Marble's source directory:

cd ~/marble/sources

Then the toolchain have to be cloned from its git repository:

git clone https://github.com/LaurentGomila/qt-android-cmake.git

We will use this to compile Marble and pack it as an apk.

Setting your PATH

You have to add the following paths to your PATH:

Android NDK:

export ANDROID_NDK=/path_to_your_NDK_install

Android SDK:

export ANDROID_SDK=/path_to_your_SDK_install

Ant:

You can get the path to the binary with:

whereis ant

After you know the path:

export ANT=/path_to_ant

Java:

Path to your Java installation, for example:

export JAVA_HOME=/usr/lib/jvm/java-7-openjdk

Qt:

For example, if you installed Qt in /opt/Qt you have to set the following on a 64 bit system:

export Qt5_host=/opt/Qt/5.4/gcc_64

And for the Android version:

export Qt5_android=/opt/Qt/5.4/android_armv7

Also specify the location of qt-android-cmake:

export Qt5_android_cmake=/path/to/qt-android-cmake

And you also need to specify your target platform (e.g.: 18):

export ANDROID_PLATFORM=android-18

Compiling Marble

First of all, create a build directory in marble's source dir:

mkdir ~/marble/build

Than change your working directory to it:

cd ~/marble/build

Then the project have to be configured with Cmake. First we will build the libraries and the plugins, after that we will build the app.

First, run the following command:

cmake -DCMAKE_TOOLCHAIN_FILE="${Qt5_android_cmake}/toolchain/android.toolchain.cmake" -DCMAKE_BUILD_TYPE=Release -DQT_NO_WEBKIT=TRUE -DQT_NO_PRINTER=TRUE  -DQT_NO_DBUS=TRUE -DCMAKE_INSTALL_PREFIX=../export ../sources/

This will generate the needed Makefile for compiling. Start the build process with the following command:

make install/strip

Generating the Android Application Package (APK)

After the build successfully finished, the files have been installed to ../export or whichever other path you passed in the -DCMAKE_INSTALL_PREFIX option to cmake. Now run the Python script src/apps/marble-maps/create-apk.py to generate the Android package:

~/marble/sources/src/apps/marble-maps/create-apk.py --target MarbleMaps.apk ../export

The script provides a number of parameters. Typical usage is as follows:

  • Testing directly on a connected device: create-apk.py --reinstall /path/to/marble/export
  • Creating an .apk locally: create-apk.py --target MarbleMaps.apk /path/to/marble/export
  • Creating a signed package for release: create-apk.py --target MarbleMaps.apk --keystore /path/to/Marble.keystore /path/to/marble/export. You'll be prompted for the required passwords (unless you pass them using the --storepass option).

All parameters of create-apk.py can be shown with its --help switch:

usage: create-apk.py [-h] [--target TARGET] [--keystore KEYSTORE]
                     [--storepass STOREPASS] [--release] [--install]
                     [--reinstall]
                     directory

Create an Android application package (APK) for Marble Maps

positional arguments:
  directory             The directory where the Android build is installed to

optional arguments:
  -h, --help            show this help message and exit
  --target TARGET       Target filename (or directory) for the .apk package
  --keystore KEYSTORE   Keystore file for signing the package
  --storepass STOREPASS
                        Keystore password for signing the package
  --release             Build a release package
  --install             Install the package to a connected device
                        (uninstalling it before, if needed)
  --reinstall           Install the package to a connected device (keeping
                        previous data intact, if any)