Installing the Prerequisites

In order to use Qt for Android, you need the following:

JDK

Java Development Kit (JDK) provided by AdoptOpenJDK for all platforms, is required to build Android apps. Other alternatives such as OpenJDK for Linux or Java SE Development Kit for Windows are also supported.

Note: As of Qt 5.15.8, JDK 11 or later is supported for Qt for Android.

Verify your installation

1
2
3
4
$ java -version
openjdk version "11.0.19" 2023-04-18
OpenJDK Runtime Environment Temurin-11.0.19+7 (build 11.0.19+7)
OpenJDK 64-Bit Server VM Temurin-11.0.19+7 (build 11.0.19+7, mixed mode)

Gradle

Gradle for building application packages (APK) and app bundles (AAB) for Android devices. Gradle is delivered with Qt 5.9, and later.

Note: Using Ant to build APKs is no longer supported.

*Step 1. *Download the latest Gradle distribution

*Step 2. *Unpack the distribution

Create a new directory C:\Gradle with File Explorer.

Open a second File Explorer window and go to the directory where the Gradle distribution was downloaded. Double-click the ZIP archive to expose the content. Drag the content folder gradle-8.1.1 to your newly created C:\Gradle folder.

Alternatively you can unpack the Gradle distribution ZIP into C:\Gradle using an archiver tool of your choice.

*Step 3. *Configure your system environment

In File Explorer right-click on the This PC (or Computer) icon, then click Properties -> Advanced System Settings -> Environmental Variables.

Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-8.1.1\bin. Click OK to save.

*Step 4. *Verify your installation

Open a console (or a Windows command prompt) and run gradle -v to run gradle and display the version, e.g.:

1
2
3
4
$ gradle -v
------------------------------------------------------------
Gradle 8.1.1
------------------------------------------------------------

Android SDK

The Android Command-line SDK Tools to install the following packages that are required to compile Qt applications for Android:

  • Platform tools
  • Build tools
  • At least one SDK platform
  • The Android NDK, which contains toolchains and debuggers for Android.

Note: Qt Creator 4.12 or later can set up the SDK Tools, NDK, and essential packages automatically. For more information, see Qt Creator: Specifying Android Device Settings.

Note: If you are using the SDK Tools 26.x or below, the JDK 8 is required. Versions higher than 8 might cause issues for the Android SDK tools.

Note: If your Qt version is earlier than v5.9, use the SDK tools package v25.2.5 or earlier.

Installing the Android SDK Essentials

After downloading and unpacking the Commandline SDK Tools, use the sdkmanager command line tool to install the essential packages:

1
2
$ sdkmanager.bat --sdk_root="D:\Programs\android-sdk" --install "cmdline-tools;latest"
$ sdkmanager.bat --sdk_root="D:\Programs\android-sdk" --install "platform-tools" "platforms;android-29" "build-tools;29.0.2" "ndk;21.3.6528147"

Android Studio or the Qt Creator’s SDK Manager UI can also be used to install the essential SDK packages.

NDK

The Android NDK can be installed using the sdkmanager tool. Alternatively, you can download it and extract it manually to a path of your choosing.

Different Qt versions depend on different NDK versions, as listed below:

Qt version NDK version Toolchain
Qt 5.14.0 or later Qt 5.13.2 or later Qt 5.12.6 or later NDK r20b or r21 android-clang
Qt 5.12.0 to 5.12.5 Qt 5.13.0 to 5.13.1 NDK r19c android-clang
Qt 5.11 and earlier NDK r10e GCC toolchain

Host Specific Configuration

Windows

The default USB driver on Windows does not allow debugging using Android Debug Bridge (ADB) tool. You must install the additional USB driver provided by the extras Android SDK package. To install it, run the following:

1
$ sdkmanager.bat --sdk_root="D:\Programs\android-sdk" --install "extras;google;usb_driver"

After the package installation is complete, install the driver from <ANDROID_SDK_ROOT>/extras/google/usb_driver. Try running a few basic adb commands now and check whether your Android device responds to them.

Qt Creator

Reference