This page contains information particular to building and running Qt applications on Android. Qt supports Android versions 6.0 (API level 23) or later.
The easiest way to develop with Qt for Android is to use Qt Creator. When you use an Android Kit with a Qt Creator project, it builds your code in addition to some Android specific files that are required for enabling Qt on Android and generating your application bundle. Qt Creator adds these files in a subdirectory of your project called android. For more information, see Android Package Templates.
On Android, apps are distributed to devices as APK packages. For distributing apps in Google Play, a different format called AAB is used instead. For more information, see Publishing to Google Play.
Use Qt Creator to build both APK and AAB package formats, or build them manually. For more information, see Deploying an Application on Android.
If an application uses plugins that depend on other modules, these modules must be listed in the application's dependencies. For more information, see Dependencies Detection.
Because of a bug in some OpenGL drivers, the mechanism used by Qt to cache text glyphs does not work as expected on all Android devices, causing text to appear scrambled. To remedy this, a workaround is in place, but it can increase memory consumption and can also affect text rendering performance. The workaround is now used by default on all devices.
You can disable the workaround by setting the QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND
environment variable to 1 or true. However, you should do so only after verifying that text appears correctly
on all targeted devices.
Modern devices often support OpenGL ES 3.0 or 3.1 in addition to 2.0. To get a suitable OpenGL context, set the requested version via QSurfaceFormat::setVersion().
Note: The header files, such as gl31.h, are only available in recent API levels, and therefore you need to target API level 21. Keep in mind also that using OpenGL ES 3.x features will result in the application breaking on older devices that only support 2.0.
Qt for Android provides a special, virtual file system which is based on the Android Assets mechanism. Files that are put
under the directory (ANDROID_PACKAGE_SOURCE_DIR/assets/) are packaged as part of your application package. These can be accessed in Qt by prefixing the
paths with assets:/
. For more information, see Porting Qt applications to Android.
Qt for Android currently has binaries for armv7a, arm64-v8a, x86 and x86-64.
If you want to support several different ABIs in your application in Google Play, the recommendation is to build an Application App Bundle (AAB) containing binaries for each of the ABIs. Based on your AAB, Google Play generates optimized Application Packages (APK) for each device requesting a download.
For more information, see Building the Android Application.
Due to a bug on some devices, when you turn off predictive text with ImhNoPredictiveText
, this property is ignored and predictive text is still enabled. To work around this, set the
QT_ANDROID_ENABLE_WORKAROUND_TO_DISABLE_PREDICTIVE_TEXT
environment variable to 1
. However, one side effect is that this environment variable can cause a problem with other keyboards such as Gboard. If
you use a language like Japanese, with Gboard, only a QWERTY keyboard is displayed. This environment variable is queried each time the keyboard is displayed, so it's possible to toggle the workaround on and off, as
necessary.
Some of the Qt modules might have features that are not supported on Android or have limitations. For more information, see QTBUG-72086.
QtActivity
or Android Activity to create a custom Activity?
QtActivity
extends Activity
and implements the logic needed to load the Qt libraries or handle events and native calls between Android and Qt. In general, extending QtActivity
is
needed if you are using any native calls. Otherwise, extending Activity
should work.
QtService
or Android Service?
The same reasoning as QtActivity
applies here. Unless you are using features that require the Qt libraries to be loaded, like native calls.
Android Fragments cannot be used with Qt. However, Qt offers it's own modular components and views with QML. You can combine multiple components in one QML view. For more information, see Qt QML.