W3cubDocs

/Qt 5.15

Getting Started with Qt for Android

Installing the Prerequisites

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

  • Java SE Development Kit (JDK) or OpenJDK (on Linux) version 6 up to 8. Versions higher than 8 might cause issues for the Android SDK command-line tools.
  • Gradle for building application packages (APK) and app bundles (AAB) for Android devices. Gradle is delivered with Qt 5.9, and later. Because Gradle scripts are not delivered with Android SDK tools since version 26.0.0, they are delivered with Qt 5.9 and 5.6.3.

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

  • The Android 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 your Qt version is earlier than v5.9, use the SDK tools package v25.2.5 or earlier.

  • 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 5.14.0 or later, Qt 5.13.2 or later, and Qt 5.12.6 or later
      • NDK r20b or r21
      • android-clang
      • Note: Qt 5.14.0 and 5.14.1 with NDK r21 have a bug fixed at QTBUG-81461.

    • Qt 5.12.0 to 5.12.5 and Qt 5.13.0 to 5.13.1
      • NDK r19c
      • android-clang
    • Qt 5.11 and below
      • NDK r10e
      • GCC toolchain

After installing the SDK tools, update the Android SDK, and then install the essential packages using Android Studio, the Qt Creator SDK Manager UI, or the sdkmanager command line tool.

Note: Make sure to unpack the Android SDK and NDK to a writeable location that Qt Creator can access later. Otherwise, Qt Creator won't be able to use sdkmanager or find all components even if they were installed manually.

Updating the Android SDK

Use the sdkmanager command line tool to update the packages list and then install the essential packages:

cd <ANDROID_SDK_ROOT>/tools/bin/
./sdkmanager --update
./sdkmanager --install "platform-tools" "platforms;android-29" "build-tools;29.0.2" "ndk-bundle"

To use the Android Emulator, install it by entering:

./sdkmanager --install "emulator" "patcher;v4"

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:

sdkmanager.bat --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.

Linux 64-bit

If you're developing on a 64-bit Linux machine, you must install the following dependencies in order to run 32-bit executables like adb, which allows Qt Creator to find devices to deploy to:

sudo apt-get install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386

To run the Android emulator, the following dependencies are also necessary:

sudo apt-get install libsdl1.2debian:i386

Qt Creator IDE

The Qt Creator IDE can be used to develop Qt applications for Android. For more information, see Qt Creator: Connecting Android Devices.

Testing Your Setup

Now you can test your development setup by running the examples shipped with the Qt installation. For more information, see Qt for Android Examples.

To develop a simple application from scratch, see Qt Creator: Creating a Mobile Application.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/android-getting-started.html