| /**************************************************************************** |
| ** |
| ** Copyright (C) 2020 The Qt Company Ltd. |
| ** 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-building.html |
| \title Qt for Android - Building from Source |
| \brief How to configure and build Qt for Android directly from source. |
| |
| Qt for Android has some requirements that you are recommended to know before |
| going through this guide. Accomplish the tasks in |
| \l{Getting Started with Qt for Android} first. |
| |
| You can download the Qt 5 sources from the \l Downloads page. |
| |
| \section1 Building on Linux |
| |
| \section2 Prepare the Build Environment |
| |
| First, install the Android SDK in one of two ways: |
| |
| \list |
| \li \l{Using the Package Manager}{Using the package manager} |
| \li \l{Using Manual Installation}{Using a manual installation} |
| \endlist |
| |
| \section3 Using the Package Manager |
| |
| For any Debian-based Linux, use the following command: |
| |
| \badcode |
| sudo apt install build-essential android-sdk openjdk-11-jdk |
| \endcode |
| |
| It is recommended to install the Android NDK using sdkmanager, with the |
| following commands: |
| |
| \badcode |
| sdkmanager --verbose --licenses |
| sdkmanager --update |
| sdkmanager "platforms;android-28" "ndk-bundle" "build-tools;28.0.3" "platform-tools" |
| \endcode |
| |
| \note If you are using the old SDK Tools packages "tools", OpenJDK 1.8 is |
| needed. It is also recommended to install the latest SDK Tools |
| "cmdline-tools" package and switch to it. |
| |
| \section3 Using Manual Installation |
| |
| You can use \l {Android: Android Studio}{Android Studio} to download and installl |
| the Android SDK packages required for developing applications for Android. For |
| more information, see \l{Android: Update your tools with the SDK Manager} |
| {Android Studio documentation}. |
| |
| \section2 Installing the License File |
| |
| If you use Qt with a commercial license, the Qt tools look for a local license file. |
| If you are using a binary installer or the commercial Qt Creator, your licenses |
| are automatically fetched and stored in your local user profile |
| (\c{$XDG_DATA_HOME/Qt/qtlicenses.ini} file). |
| |
| If you do not use any binary installer or Qt Creator, you can download |
| the respective license file from your \l {Qt Account} Web portal and save |
| it to your user profile as \c{$HOME/.qt-license}. If you prefer a |
| different location or file name, you need to set the \c{QT_LICENSE_FILE} |
| environment variable to the respective file path. |
| |
| \section2 Unpacking the Archive |
| |
| Unpack the archive if you have not done so already. For example, |
| if you have the \c{qt-everywhere-opensource-src-%VERSION%.tar.gz} |
| package, type the following commands at a command line prompt: |
| |
| \snippet snippets/code/doc_src_installation.qdoc 0 |
| |
| This creates the directory \c{/tmp/qt-everywhere-opensource-src-%VERSION%} |
| containing the files from the archive. We only support the GNU version of |
| the tar archiving utility. Note that on some systems it is called gtar. |
| |
| \section2 Configuring and Building |
| |
| Set the following environment variables, and add them to your \c{PATH}; |
| preferably at the end of \c{~/.profile}: |
| |
| \badcode |
| export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 |
| export PATH=$PATH:$JAVA_HOME/bin |
| \endcode |
| |
| To configure Qt for Android, run the following: |
| |
| \badcode |
| cd /tmp/qt-everywhere-opensource-src-%VERSION% |
| ./configure -xplatform android-clang --disable-rpath -nomake tests -nomake examples -android-ndk <path/to/sdk>/ndk-bundle/ -android-sdk <path/to/sdk> -no-warnings-are-errors |
| \endcode |
| |
| The \l{Qt Configure Options}{Configure Options} page contains more information |
| about the configure options. |
| |
| You may provide the \c{-android-abis} parameter to limit the Android ABIs |
| being built, with either of: \e{armeabi-v7a}, \e{arm64-v8a}, \e{x86}, or \e{x86_64}: |
| |
| \badcode |
| -android-abis armeabi-v7a,arm64-v8a |
| \endcode |
| |
| If the parameter is not specified, Qt is built for all supported ABIs. |
| |
| To build the configured Qt code, run the following command: |
| \badcode |
| make -j$(nproc) |
| \endcode |
| |
| \note \e{nproc} is optional. It represents the number of parallel jobs your |
| system can do. |
| |
| Then install the built Qt for Android: |
| \badcode |
| make install |
| \endcode |
| |
| If you haven't provided the \c{--prefix <install-dir>} configure option, the |
| installation is placed under \c{/usr/local/Qt-<version>}. In Debian/Ubuntu, |
| you should prefix the \c make command with the \c sudo command. |
| |
| \section1 Building on Windows |
| |
| First, you can use \l {Android: Android Studio}{Android Studio} to download |
| and install the Android SDK packages required for developing applications |
| for Android. For more information, see \l{Android: Update your tools with the SDK Manager} |
| {Android Studio documentation}. |
| |
| |
| \section2 Preparing the Build Environment |
| |
| Install the following: |
| |
| \list |
| \li \l{Perl} |
| \li A JDK 1.8 package such as \l{Java SE Development Kit}{JDK} or |
| \l{OpenJDK} or \l{AdoptOpenJDK}. |
| \li \b {MinGW 7.3} toolchain |
| \endlist |
| |
| Then set the respective environment variables, replacing them with the |
| appropriate values: |
| |
| \badcode |
| set "JDK_ROOT=<JDK_ROOT_PATH>\bin\" |
| set "MINGW_ROOT=<MINGW_ROOT_PATH>" |
| set "PERL_ROOT=<PERL_ROOT_PATH>" |
| \endcode |
| |
| Open the \c cmd.exe window and verify that: |
| |
| \list |
| \li \c{where gcc.exe} lists \e{<MINGW_ROOT>.exe} first before \e{<PERL_ROOT>.exe}. |
| \li \c{where mingw32-make.exe} lists \e{<MINGW_ROOT32>-make.exe} first. |
| \li \c{where javac.exe} lists \e{<JDK_ROOT>} first. |
| \endlist |
| |
| \note Currently, it is not possible to use Microsoft's compilers to build |
| the Windows host tools for Qt Android. |
| |
| \section2 Setting a Commercial License |
| |
| If you have a commercially licensed Qt, install your license file. If you're using |
| a binary installer or the commercial Qt Creator, your licenses are automatically |
| fetched and stored in your local user profile |
| \c{%USERPROFILE%\AppData\Roaming\Qt\qtlicenses.ini}. Alternatively, you can download |
| the respective license file from your Qt Account web portal and save it to your user |
| profile as \c{%USERPROFILE%\.qt-license}. If you prefer a different location or file |
| name, you need to set the \c QT_LICENSE_FILE environment variable to the respective |
| file path. |
| |
| \section2 Building the Sources |
| |
| Next, unpack the archive. Uncompress the files into the directory in which |
| you want Qt installed, for example: \c{C:\Qt\%VERSION%}. This install path must not contain any |
| spaces or Windows-specific file system characters. |
| |
| Run the following command to configure Qt: |
| |
| \badcode |
| cd <decompressed_source_code_folder> |
| configure.bat -prefix <path to install Qt to> -platform win32-g++ -opengl es2 -xplatform android-clang -android-sdk <ANDROID_SDK_PATH> -android-ndk <ANDROID_SDK_PATH>\ndk-bundle\ -nomake tests -nomake examples |
| \endcode |
| |
| The \l{Qt Configure Options}{Configure Options} page contains more information |
| about the configure options. |
| |
| To build the configured Qt for Android code, run the following: |
| |
| \badcode |
| mingw32-make.exe -j<N> |
| \endcode |
| |
| \note \e{<N>} is optional. It represents the number of parallel jobs your |
| system can do. |
| |
| Now, to install Qt, run the following command: |
| |
| \badcode |
| mingw32-make.exe install |
| \endcode |
| */ |