This is a text-only version of the following page on https://raymii.org:
---
Title : A docker image for Qt 5.15 LTS for Android, including OpenSSL and the KDE patch collection
Author : Remy van Elst
Date : 13-9-2023 22:00
URL : https://raymii.org/s/blog/Qt_5.15_LTS_Docker_Image_for_Android_with_OpenSSL.html
Format : Markdown/HTML
---
Recently I got an email from Google regarding the API level of [Leaf Node Monitoring](https://leafnode.nl), my open source monitoring app for Windows, Linux and Android. The Play Store version must be updated to target API level 33.
For Windows and Linux I'm building the app automatically in a CI environment but the Android build was still a manual process. Until now, because after a bunch of messing around with Android NDK versions, OpenSSL library paths and Qt compile flags I can automatically build Leaf Node Monitoring in my CI.
I'm using Woodpecker CI and that requires every build step to be executed in a Docker image. There are a few Qt docker images floating around but they are all using the pre-built 5.15.2 version by extracting it from the Qt Online Installer. That version is quite old, 5.15.15 LTS was released [a few days ago for Commercial License Holders](http://web.archive.org/web/20230902132649/https://www.qt.io/blog/commercial-lts-qt-5.15.15-released) on August 31, so after 1 year it will become available as open source.
My docker image builds Qt from source using the `5.15 KDE Qt Patch Collection` branch for Android and it includes OpenSSL. This is as far as I know the most up to date docker image for Qt 5.15, currently at 5.15.10 LTS.
Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below:
I'm developing an open source monitoring app called Leaf Node Monitoring, for windows, linux & android. Go check it out!
Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.
You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!
Why still use Qt 5.15 you might ask? The short answer is Windows 7 compatibility,
Qt 6 dropped that and I find it wasteful to not support computers that still
work perfectly fine. I have a strict policy that all code also compiles and is
tested on Qt 6, but my main distribution channel is Qt 5.15.
If you'd like an image for regular Linux, send me an email. If there is enough
interest I could make one.
### A bit of history regarding the Qt 5.15 policy change
Remember, 2 years ago in 2021, the Qt Company made a lot of people very angry by
closing down [the source code of Qt 5.15]
(http://web.archive.org/web/20230105030605/https://www.phoronix.com/news/Qt-5.15-LTS-Commercial-Phase).
But due to an [agreement with the KDE Free Qt Foundation]
(
http://web.archive.org/web/20230823114232/https://kde.org/community/whatiskde/kdefreeqtfoundation/)
they must release the source code within 12 months otherwise KDE can release Qt
under a BSD style license.
That would be bad for the Qt Company because no one then has to pay for a
license anymore and they don't have to release source code. Now you must pay
for a license or release your source code under the GPLv3 (or fiddle with the
LGPL).
So exactly 1 year (-1 day) after every 5.15 release, the Qt Company drops the
source code for the 5.15 LTS version, [here is my article on the first release
after the policy change, 5.15.3](/s/blog/Qt_5.15.3_OpenSource_released.html).
The KDE folks [maintain a branch]
(http://web.archive.org/web/20230902132008/https://www.phoronix.com/news/KDE-Qt-5-Patch-Collection)
with backported patches and the most recent 5.15 LTS code. I'm using that branch
for my Android app and for the Linux version. Windows still uses 5.15.2 from the
installer due to an issue with ANGLE, QML will not work with a cross-compiled
version (yet)
### My docker image
The docker image includes most of the Android tools as local zip files
that are `COPY`'d into the image. I want to preserve those as Google might
remove them from the `sdkmanager` tool any time. I mirror Qt source code
at home so that will stay available for me at least, which is why it's not
in the docker image assets.
You can find the docker image here: [https://hub.docker.com/repositories/raymii/qt](https://hub.docker.com/layers/raymii/qt/5.15-android-source/images/sha256-18662e5a733b5959b21bb554b38e3636a9a88e19e89d5af47d2e0af9387bef6f?context=repo)
You can pull it locally using the following command:
docker pull raymii/qt:5.15-android-source
The source code and assets are up on Github: [https://github.com/RaymiiOrg/Qt-5.15-from-source-build-Docker][2]
If you use the image in your build system, make sure to sync up the
`NDK_VERSION` and `BUILD_TOOLS` in the Dockerfile with the `ndkVersion`
and `buildToolsVersion` in your `build.gradle` file:
Dockerfile:
SDK_BUILD_TOOLS=30.0.2
NDK_VERSION=22.1.7171670
build.gradle:
buildToolsVersion '30.0.2'
ndkVersion '22.1.7171670'
My Woodpecker CI file contains the following code to build the debug build
for Leaf Node Monitoring, as an example reference on how to use the Docker
image:
build-qt5-15-10-android-debug-arm64-v8a:
image: raymii/qt:5.15-android-source
volumes:
- /ccache:/ccache
environment:
- CCACHE_DIR=/ccache/
- ANDROID_ABIS="arm64-v8a"
commands:
- export PATH=$PATH:/usr/local/Qt-5.15.10/bin:$CI_WORKSPACE/build/bin/
- sudo chmod -R a+w .
- mkdir build-debug
- cd build-debug
- qmake .. CONFIG+=debug CONFIG+=qtquickcompiler CONFIG+=ccache -spec android-clang ANDROID_ABIS="$ANDROID_ABIS"
- make -j
- make -j apk_install_target
- sudo chown -R $(whoami) $ANDROID_HOME
- androiddeployqt --input android-$PROJECTNAME-deployment-settings.json --gradle --output ./android-build/
The [KDE sysadmin CI images][3] dockerfile was the most helpful in finding the
right NDK version for 5.15.10. The Qt documentation lists a different version (21.0.6113669)
which, for me, did not work with API level 33. All kinds of errors regarding
unknown Java methods or other strange errors (`AAPT: error: attribute android:allowNativeHeapPointerTagging not found.`). This (translated) [article][5] was
also helpful.
### The asset files you need
Github blocks files larger than 100 MB, so you'll need to download the assets
yourself, including their md5sum here:
b99a69907ca29e8181852645328b6004 ./android-ndk-r22b-linux-x86_64.zip
a858219c60cf559a1e206fd9be7f5c70 ./build-tools_r30.0.2-linux.zip
ff016ef6fe902a22839895dbb4b8afb6 ./cmake-3.23.3-linux-x86_64.sh
ca155336e152acb9f40697ef93772503 ./commandlinetools-linux-6609375_latest.zip
e687a5b5cc7bb3af39d0e9528ac4a84c ./platform-31_r01.zip
d811f1344b16c7113733cc7b801efdab ./platform-tools_r34.0.4-linux.zip
They are in the docker image that is on Docker hub however, but if you want to build the image
yourself you need these files.
[1]: https://hub.docker.com/layers/raymii/qt/5.15-android-source/images/sha256-18662e5a733b5959b21bb554b38e3636a9a88e19e89d5af47d2e0af9387bef6f?context=repo
[2]: https://github.com/RaymiiOrg/Qt-5.15-from-source-build-Docker
[3]: https://web.archive.org/web/20230913183030/https://invent.kde.org/sysadmin/ci-images/-/raw/master/android-qt515/Dockerfile?ref_type=heads
[5]: https://web.archive.org/web/20230913183421/https://habr.com/ru/articles/599033/
---
License:
All the text on this website is free as in freedom unless stated otherwise.
This means you can use it in any way you want, you can copy it, change it
the way you like and republish it, as long as you release the (modified)
content under the same license to give others the same freedoms you've got
and place my name and a link to this site with the article as source.
This site uses Google Analytics for statistics and Google Adwords for
advertisements. You are tracked and Google knows everything about you.
Use an adblocker like ublock-origin if you don't want it.
All the code on this website is licensed under the GNU GPL v3 license
unless already licensed under a license which does not allows this form
of licensing or if another license is stated on that page / in that software:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Just to be clear, the information on this website is for meant for educational
purposes and you use it at your own risk. I do not take responsibility if you
screw something up. Use common sense, do not 'rm -rf /' as root for example.
If you have any questions then do not hesitate to contact me.
See https://raymii.org/s/static/About.html for details.