Android/Environment via Container: Difference between revisions

From KDE Community Wiki
(Moved from general Android page)
 
No edit summary
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Use Docker Container for KDE on Android Development =
= Using Docker for KDE on Android Development =
This is the easiest way to start cross-compiling and developing Qt applications for Android. The explained Docker image will install all dependencies and setup all environment variables automatically. By this, it closely follows the steps explained in the detailed system setup guide:
This is the easiest way to start cross-compiling and developing Qt applications for Android. The explained Docker image will install all dependencies and setup all environment variables automatically. By this, it closely follows the steps explained in the detailed system setup guide:
* [[Android/Environment|Setup Cross-Building Environment for KDE on Android]]
* [[Android/Environment|Setup Cross-Building Environment for KDE on Android]]


== Use Docker Container ==
== Setting up ==
First, you must install Docker on your system, which should be available via your distribution. Then you only have to checkout the Docker image configuration in <code>git clone git://anongit.kde.org/android-builder.git</code>.
This image alone contains a working Android SDK, NDK and Qt binaries. The easiest is to access it like this (it will be downloaded the first time you use it):
<syntaxhighlight lang="bash">
docker run -ti --rm kdeorg/android-arm-sdk bash
</syntaxhighlight>
 
Here one can start developing at ease in an environment welcoming to projects that use cmake, Qt, ECM, etc.


Then in folder <code>image</code> perform the following commands to build, then create, and finally to run your KDE on Android build image:
== Building an application ==
To make it easy to compile applications we put some scripts to get started. They can be triggered like this:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
cd image
docker run -ti --rm kdeorg/android-arm-sdk /opt/helpers/build-generic <appname>
docker build -t kde-android-sdk .
docker create -ti --name myproject kde-android-sdk bash
docker start -i myproject
</syntaxhighlight>
</syntaxhighlight>
More details can be found in the README.md file in the checked out repository.


==== Change Container Size ====
The following command will compile okular with all its dependencies and output an apk to our /tmp directory.
By default Docker containers have a size of 10GB. This is sufficient for the typical use case, but usually much too small if you setup a full cross-building toolchain. For this, you have to increase the default container size (note: the following deletes all your current containers, hence do backups and do it with care!)
* Documentation: https://docs.docker.com/engine/reference/commandline/daemon/
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
service docker stop
docker run -ti --rm -v /tmp:/output kdeorg/android-arm-sdk /opt/helpers/build-generic okular
rm -rf /var/lib/docker
service docker start
docker -d --storage-opt dm.basesize=20G &
</syntaxhighlight>
</syntaxhighlight>
== Tricks ==
* build-generic fetch the dependencies of <appname>, build them and then build <appname>, outputting an apk to /output. Therefore a volume to /output will catch the result. e.g. <code>-v $HOME/apks:/output</code>
* if we want to develop locally a project, we can also use volumes and put them in the home directory. e.g. <code>-v /home/apol/devel/frameworks/kate:/home/user/src/kate</code>.
* Note we are passing kdeorg/android-arm-sdk, this is to produce 32-bit arm images, there's also kdeorg/android-aarch64-sdk available as well.

Revision as of 23:08, 5 August 2019

Using Docker for KDE on Android Development

This is the easiest way to start cross-compiling and developing Qt applications for Android. The explained Docker image will install all dependencies and setup all environment variables automatically. By this, it closely follows the steps explained in the detailed system setup guide:

Setting up

This image alone contains a working Android SDK, NDK and Qt binaries. The easiest is to access it like this (it will be downloaded the first time you use it):

docker run -ti --rm kdeorg/android-arm-sdk bash

Here one can start developing at ease in an environment welcoming to projects that use cmake, Qt, ECM, etc.

Building an application

To make it easy to compile applications we put some scripts to get started. They can be triggered like this:

docker run -ti --rm kdeorg/android-arm-sdk /opt/helpers/build-generic <appname>

The following command will compile okular with all its dependencies and output an apk to our /tmp directory.

docker run -ti --rm -v /tmp:/output kdeorg/android-arm-sdk /opt/helpers/build-generic okular

Tricks

  • build-generic fetch the dependencies of <appname>, build them and then build <appname>, outputting an apk to /output. Therefore a volume to /output will catch the result. e.g. -v $HOME/apks:/output
  • if we want to develop locally a project, we can also use volumes and put them in the home directory. e.g. -v /home/apol/devel/frameworks/kate:/home/user/src/kate.
  • Note we are passing kdeorg/android-arm-sdk, this is to produce 32-bit arm images, there's also kdeorg/android-aarch64-sdk available as well.