2020-04-03 14:33:15 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2020-04-07 14:46:21 +00:00
|
|
|
** Copyright (C) 2020 The Qt Company Ltd.
|
2020-04-03 14:33:15 +00:00
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
**
|
|
|
|
** This file is part of the documentation of the Qt Toolkit.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:FDL$
|
|
|
|
** Commercial License Usage
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
**
|
|
|
|
** GNU Free Documentation License Usage
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Free
|
|
|
|
** Documentation License version 1.3 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file included in the packaging of
|
|
|
|
** this file. Please review the following information to ensure
|
|
|
|
** the GNU Free Documentation License version 1.3 requirements
|
|
|
|
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\page android.html
|
|
|
|
\title Qt for Android
|
|
|
|
\brief Provides information about Android support in Qt.
|
|
|
|
\ingroup supportedplatform
|
2020-09-02 11:40:48 +00:00
|
|
|
\previouspage android_runtime_licensing_notes.html
|
|
|
|
\nextpage android-getting-started.html
|
2020-04-03 14:33:15 +00:00
|
|
|
|
2020-10-16 06:19:37 +00:00
|
|
|
Qt for Android enables you to run Qt applications on Android devices.
|
2020-04-07 14:46:21 +00:00
|
|
|
All Qt modules (essentials and add-ons) are supported except the following:
|
|
|
|
|
|
|
|
\list
|
2020-05-14 06:54:12 +00:00
|
|
|
\li \l{Qt WebEngine}
|
|
|
|
\li \l{Qt Virtual Keyboard}
|
|
|
|
\li Platform-specific extras: \l{Qt Mac Extras}, \l{Qt Windows Extras}, and
|
|
|
|
\l{Qt X11 Extras}
|
2020-04-07 14:46:21 +00:00
|
|
|
\endlist
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
The following configurations are supported:
|
|
|
|
|
|
|
|
\include supported-platforms.qdocinc android
|
|
|
|
|
|
|
|
The following list summarizes what you can do with Qt for Android:
|
|
|
|
|
|
|
|
\list
|
2020-04-07 14:46:21 +00:00
|
|
|
\li Run \l{Qt Widgets}{Widget-based} and \l{QML Applications}{QML}
|
|
|
|
applications on a device or an emulator.
|
|
|
|
\li Support for the \l{Material Style}{Material Style} with
|
|
|
|
Qt Quick Controls.
|
|
|
|
\li Handle \l{Qt Multimedia}{Multimedia} content in your
|
|
|
|
Qt Quick 2 applications.
|
|
|
|
\li Get \l{Qt Sensors}{sensor} readings.
|
|
|
|
\li Retrieve positioning data using satellite or network information.
|
|
|
|
\li Connect and exchange data with \l{Qt Bluetooth}{Bluetooth}
|
|
|
|
and \l{Qt NFC}{NFC}-enabled devices.
|
|
|
|
\li Integrate Java code into your application using \l{Qt Android Extras}.
|
|
|
|
\li Develop secure applications using OpenSSL library.
|
|
|
|
\li Create \l{Android Services}.
|
|
|
|
\li Create and deploy Application Package (APK) and Android App Bundle (AAB)
|
|
|
|
packages using Qt Creator.
|
2020-04-03 14:33:15 +00:00
|
|
|
\endlist
|
|
|
|
|
|
|
|
The following topics provide more details about how to use Qt for Android:
|
|
|
|
\list
|
|
|
|
\li \l{Getting Started with Qt for Android}{Getting Started}
|
2020-09-02 11:40:48 +00:00
|
|
|
\li \l{Qt for Android - Building from Source}
|
2020-04-03 14:33:15 +00:00
|
|
|
\li \l{Porting to Android}{Porting a Qt Application}
|
2020-04-07 14:46:21 +00:00
|
|
|
\li \l{Qt for Android Examples}{Qt Examples on Android}
|
|
|
|
\li \l{Deploying an Application on Android}
|
|
|
|
\li \l{Qt Creator: Deploying Applications to Android Devices}
|
2020-04-03 14:33:15 +00:00
|
|
|
\li \l{Adding OpenSSL Support for Android}
|
|
|
|
\li \l{Android Services}{Creating Android Services}
|
2020-04-07 14:46:21 +00:00
|
|
|
\li \l{Third-party Android Libraries}
|
|
|
|
{Including third-party Android libraries in an application}
|
2020-04-03 14:33:15 +00:00
|
|
|
\li \l{Publishing to Google Play}
|
2020-04-15 08:21:27 +00:00
|
|
|
\li \l{Android Platform Notes}
|
2020-04-03 14:33:15 +00:00
|
|
|
\li \l{Android GNU C++ run-time licensing}
|
|
|
|
\endlist
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\page android-getting-started.html
|
|
|
|
\title Getting Started with Qt for Android
|
|
|
|
\brief Provides instructions to install and configure your development environment.
|
2020-09-02 11:40:48 +00:00
|
|
|
\previouspage android.html
|
|
|
|
\nextpage android-building.html
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
\section1 Installing the Prerequisites
|
|
|
|
|
|
|
|
In order to use \l{Qt for Android}, you need the following:
|
|
|
|
|
|
|
|
\list
|
2020-08-10 11:58:35 +00:00
|
|
|
\li Java Development Kit (JDK) provided by \l{AdoptOpenJDK} for all platforms,
|
|
|
|
is required to build Android apps. Other alternatives such as \l{OpenJDK}
|
|
|
|
for Linux or \l{Java SE Development Kit} for Windows are also supported.
|
2020-04-07 14:46:21 +00:00
|
|
|
|
|
|
|
\li \l{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.
|
|
|
|
|
|
|
|
\target android-sdk
|
2020-08-10 11:58:35 +00:00
|
|
|
\li \l{Android: The Android SDK Tools}{The Android Command-line SDK Tools}
|
2020-04-07 14:46:21 +00:00
|
|
|
to install the following packages that are required to compile Qt
|
|
|
|
applications for Android:
|
|
|
|
|
2020-04-03 14:33:15 +00:00
|
|
|
\list
|
2020-04-07 14:46:21 +00:00
|
|
|
\li Platform tools
|
|
|
|
\li Build tools
|
|
|
|
\li At least one SDK platform
|
|
|
|
\li \l {android-ndk}{The Android NDK}, which contains toolchains
|
|
|
|
and debuggers for Android.
|
2020-04-03 14:33:15 +00:00
|
|
|
\endlist
|
2020-04-07 14:46:21 +00:00
|
|
|
|
|
|
|
\note Qt Creator 4.12 or later can set up the SDK Tools, NDK, and
|
|
|
|
essential packages automatically. For more information, see
|
|
|
|
\l {Qt Creator: Specifying Android Device Settings}.
|
|
|
|
|
2020-08-10 11:58:35 +00:00
|
|
|
\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 \l {android-sdk}{the Android SDK tools}.
|
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
\note If your Qt version is earlier than v5.9, use the SDK tools package
|
|
|
|
v25.2.5 or earlier.
|
|
|
|
|
|
|
|
\target android-ndk
|
|
|
|
\li \l{Android: The Android NDK}{The Android NDK}
|
|
|
|
can be installed using the \c 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:
|
|
|
|
|
2020-04-03 14:33:15 +00:00
|
|
|
\list
|
2020-04-07 14:46:21 +00:00
|
|
|
\li Qt 5.14.0 or later, Qt 5.13.2 or later, and Qt 5.12.6 or later
|
|
|
|
\list
|
|
|
|
\li NDK r20b or r21
|
|
|
|
\li \e android-clang
|
|
|
|
\li \note Qt 5.14.0 and 5.14.1 with NDK r21 have a bug fixed at
|
|
|
|
\l {QTBUG-81461}.
|
|
|
|
\endlist
|
|
|
|
\li Qt 5.12.0 to 5.12.5 and Qt 5.13.0 to 5.13.1
|
|
|
|
\list
|
|
|
|
\li NDK r19c
|
|
|
|
\li \e android-clang
|
|
|
|
\endlist
|
|
|
|
\li Qt 5.11 and below
|
|
|
|
\list
|
|
|
|
\li NDK r10e
|
|
|
|
\li GCC toolchain
|
|
|
|
\endlist
|
2020-04-03 14:33:15 +00:00
|
|
|
\endlist
|
|
|
|
\endlist
|
|
|
|
|
2020-08-10 11:58:35 +00:00
|
|
|
After downloading and unpacking the SDK tools, install the essential packages
|
|
|
|
using \l {Android: Android Studio}{Android Studio}, the Qt Creator
|
|
|
|
\l{Qt Creator: Managing Android SDK Packages}{SDK Manager UI}, or the
|
|
|
|
\l{Android: sdkmanager}{sdkmanager} command line tool.
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
\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 \c sdkmanager or find all
|
|
|
|
components even if they were installed manually.
|
|
|
|
|
|
|
|
\section2 Updating the Android SDK
|
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
Use the \c sdkmanager command line tool to update the packages list and then
|
|
|
|
install the essential packages:
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
\badcode
|
2020-04-07 14:46:21 +00:00
|
|
|
cd <ANDROID_SDK_ROOT>/tools/bin/
|
2020-08-10 11:58:35 +00:00
|
|
|
./sdkmanager --sdk_root=<ANDROID_SDK_ROOT> --install "cmdline-tools;latest"
|
|
|
|
./sdkmanager --sdk_root=<ANDROID_SDK_ROOT> --install "platform-tools" "platforms;android-29" "build-tools;29.0.2" "ndk;21.1.6352462"
|
2020-04-03 14:33:15 +00:00
|
|
|
\endcode
|
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
To use the \l {Android: Android Emulator}{Android Emulator}, install it by
|
|
|
|
entering:
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
\badcode
|
2020-08-10 11:58:35 +00:00
|
|
|
./sdkmanager --sdk_root=<ANDROID_SDK_ROOT> --install "emulator" "patcher;v4"
|
2020-04-03 14:33:15 +00:00
|
|
|
\endcode
|
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
\section1 Host Specific Configuration
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
\section2 Windows
|
|
|
|
|
|
|
|
The default USB driver on Windows does not allow debugging using
|
|
|
|
Android Debug Bridge (ADB) tool. You must install the additional USB driver
|
2020-04-07 14:46:21 +00:00
|
|
|
provided by the \e extras Android SDK package. To install it, run the following:
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
\badcode
|
2020-08-10 11:58:35 +00:00
|
|
|
sdkmanager.bat --sdk_root=<ANDROID_SDK_ROOT> --install "extras;google;usb_driver"
|
2020-04-03 14:33:15 +00:00
|
|
|
\endcode
|
|
|
|
|
|
|
|
After the package installation is complete, install the driver from
|
|
|
|
\c{<ANDROID_SDK_ROOT>/extras/google/usb_driver}. Try running a few basic
|
2020-04-07 14:46:21 +00:00
|
|
|
\l{Android: adb}{adb} commands now and check whether your Android device
|
|
|
|
responds to them.
|
2020-04-03 14:33:15 +00:00
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
\section2 Linux 64-bit
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
If you're developing on a 64-bit Linux machine, you must install the
|
|
|
|
following dependencies in order to run 32-bit executables like \c adb, which
|
|
|
|
allows Qt Creator to find devices to deploy to:
|
|
|
|
|
|
|
|
\badcode
|
|
|
|
sudo apt-get install libstdc++6:i386 libgcc1:i386 zlib1g:i386 libncurses5:i386
|
|
|
|
\endcode
|
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
\target emulator dependencies
|
|
|
|
To run the Android emulator, the following dependencies are also necessary:
|
2020-04-03 14:33:15 +00:00
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
\badcode
|
2020-04-03 14:33:15 +00:00
|
|
|
sudo apt-get install libsdl1.2debian:i386
|
|
|
|
\endcode
|
|
|
|
|
|
|
|
\section2 Qt Creator IDE
|
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
The Qt Creator IDE can be used to develop Qt applications for Android. For more
|
|
|
|
information, see \l{Qt Creator: Connecting Android Devices}.
|
2020-04-03 14:33:15 +00:00
|
|
|
|
|
|
|
\section1 Testing Your Setup
|
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
Now you can test your development setup by running the examples shipped with the
|
|
|
|
Qt installation. For more information, see \l {Qt for Android Examples}.
|
2020-04-03 14:33:15 +00:00
|
|
|
|
2020-04-07 14:46:21 +00:00
|
|
|
To develop a simple application from scratch, see
|
|
|
|
\l {Qt Creator: Creating a Mobile Application}.
|
2020-04-03 14:33:15 +00:00
|
|
|
*/
|