- Qt 6.10
- Product information
- Supported Platforms
- Qt for Android
- Qt for Android - Building from Source
- Qt 6.10.2 Reference Documentation

Supported versions selection guidelines ◦ Building projects from command line

# Qt for Android - Building from Source

This page describes the process of configuring and building Qt for Android. To download and install a pre-built Qt for Android, follow the instructions on the Getting Started with Qt page.

## Prerequisites

To build Qt for Android from source please ensure all requirements from Getting Started with Qt for Android are met before continuing.

### Windows

Building Qt for Android on Windows also requires the following software:

- Mingw-w64 13.1 toolchain

Note: Qt for Android does not support building from source with Microsoft Visual C++ (MSVC).

Install the prerequisites and append their binary paths to the system `PATH`:

     set MINGW_ROOT=<MINGW_ROOT_PATH>\bin
     set PATH=%MINGW_ROOT%;%PATH%

To verify the installation, run:

     where mingw32-make.exe

The command should list mingw32-make.exe under the path <MINGW_ROOT> first.

## Getting the Sources

You can download the Qt sources from the Qt Downloads page, or follow the wiki guide for Getting the source code.

## Configuring

With Qt 6, you can build Qt for Android from source code using `CMake`. Qt 6 for Android requires a host Qt build, which means to build Qt for Android, you need to build Qt for the desktop platform used as a host (that is, Linux, macOS, or Windows). See Cross-compiling Qt for details.

To configure Qt for Android, create a shadow build directory to keep the source directory clean:

     mkdir -p ~/dev/build-qt-android
     cd ~/dev/build-qt-android

Qt for Android supports the following device architectures (ABIs): `arm64-v8a`, `x86_64`, `x86`, and `armeabi-v7a`

And then run the configure script from within the build directory you just created:

     <qt5_super_repo_path>/configure -prefix <install_path> -qt-host-path <qt_host_path> \
         -android-abis <abi> -android-sdk ~/Android/Sdk -android-ndk ~/Android/Sdk/ndk/27.2.12479018

The Android SDK is commonly installed by Qt Creator or Android Studio in the following locations:

- Linux: ~/Android/Sdk/
- macOS: ~/Library/Android/sdk/
- Windows: C:\Users\<USER>\AppData\Local\Android\Sdk\

Note: configure always uses the Ninja generator and build tool if a `ninja` executable is available. Ninja is cross-platform, feature-rich, performant, and recommended on all platforms. The use of other generators might work but is not officially supported.

## Advanced Configure Arguments

Before exploring this section, see Qt Configure Options, which contains more information about the configure options.

Qt for Android contains Java code compiled into *.jar files with the javac compiler. To set the javac version for source and target, use -android-javac-source and -android-javac-target respectively:

     -android-javac-source 8 -android-javac-target 8

To build Qt as a developer build instead of a prefix build, use the following instead of the `-prefix` argument:

     -developer-build

The `-qt-host-path` should point to the `qtbase` directory in the host build directory in a host developer build. For example: `~/dev/build-qt-host/qtbase`.

## Building

To build Qt, run the following command:

     cmake --build . --parallel

## Installing

For prefix builds, to install Qt, run the following command:

     cmake --install .

On Unix, if you haven't provided the `-prefix <install_path>` configure option, the installation is placed under `/usr/local/Qt-<version>`, in that case, you would need to use `sudo` with the install command.

Supported versions selection guidelines ◦ Building projects from command line