Android ndk qt creator

Qt Documentation

Contents

Qt for Android has some requirements that you are recommended to know before going through this guide. Accomplish the tasks in Getting Started with Qt for Android first.

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

Building on Linux

Prepare the Build Environment

First, install the Android SDK in one of two ways:

Using Manual Installation

Using Qt Creator

Using Android Studio

You can use Android Studio to download and installl the Android SDK packages required for developing applications for Android. For more information, see Android Studio documentation.

Building on Linux

To build Qt for Android under a Linux environment, follow the steps below:

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 ( $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 Qt Account Web portal and save it to your user profile as $HOME/.qt-license . If you prefer a different location or file name, you need to set the QT_LICENSE_FILE environment variable to the respective file path.

Unpacking the Archive

If you have downloaded the source code archive from Qt Downloads, then unpack the archive if you have not done so already. For example, if you have the qt-everywhere-src-%VERSION%.tar.xz package, type the following commands at a command line prompt:

This creates the directory /tmp/qt-everywhere-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.

Otherwise if you cloned the source code from Git, the source will be under qt5 folder.

Configuring and Building on Linux

Set the following environment variables, and add them to your PATH ; preferably at the end of

Note: JDK 11 or earlier must be used to properly build Qt for Android.

Note: We use OpenJDK here, but you can also use other JDK alternatives such as AdoptOpenJDK.

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

Qt Configure Options contains more information about the configure options.

You can customize your build configuration in a more advanced manner. For more information, see Advanced Build Arguments.

To build the configured Qt code, run the following command:

Note: nproc is optional. It represents the number of parallel jobs your system can do.

Then install the built Qt for Android:

If you haven’t provided the —prefix configure option, the installation is placed under /usr/local/Qt- . In Debian/Ubuntu, you should prefix the make command with the sudo command.

Building on Windows

To build Qt for Android under a Windows environment, follow the steps below:

Preparing the Build Environment

Install the following:

Then set the respective environment variables from the Environment Variables system UI, or from the build command line prompt. For the default Command prompt :

Then, in the command line prompt, verify that:

The command should list gcc.exe under the path first.

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

Читайте также:  Визе каре 365 для андроид

The command should list javac.exe under the path first.

Note: JDK 11 or earlier must be used to properly build Qt for Android.

Note: Qt for Android does not support building with Microsoft Visual C++ (MSVC), we only support building with MinGW.

Installing the License File

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 %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 %USERPROFILE%\.qt-license . If you prefer a different location or file name, you need to set the QT_LICENSE_FILE environment variable to the respective file path.

Configuring and Building on Windows

If you have downloaded the source code archive from Qt Downloads, unpack the archive. Uncompress the files into a temporary folder, for example, C:\Qt\Build\Src_%VERSION% . This path must not contain any spaces or Windows-specific file system characters.

Run the following command to configure Qt:

Qt Configure Options contains more information about the configure options.

You can customize your build configuration in a more advanced manner. For more information, see Advanced Build Arguments.

To build the configured Qt for Android code, run the following:

Note: is optional. It represents the number of parallel jobs your system can do.

Now, to install Qt, run the following command:

Advanced Build Arguments

You may provide the -android-abis parameter to limit the Android ABIs being built, with either of: armeabi-v7a, arm64-v8a, x86, or x86_64:

Note: If the parameter is not specified, Qt is built for all supported ABIs.

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

To debug Qt with a developer build instead of a prefix build, use the following instead of -prefix argument:

A developer build is meant to be used directly from the build directory.

Note: A developer build takes more storage than a prefix build.

Building Separate Modules

It is possible to build specific Qt modules only. There are two options:

    Use the configured qt5 build with the following command:

The to install those modules, use:

Note: On Windows, use mingw32-make.exe instead.

Configure and build qtbase only, then use the resulting qmake to build any other module. The only difference is that the configure script in qtbase directory has to be used:

В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Источник

Qt Documentation

Contents

Installing the Prerequisites

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

    Java Development Kit (JDK) provided by AdoptOpenJDK for all platforms, is required to build Android apps. Other alternatives such as OpenJDK for Linux or Java SE Development Kit for Windows are also supported.

Note: JDK 11 or earlier must be used when using Qt for Android.

Gradle for building application packages (APK) and app bundles (AAB) for Android devices. Gradle is delivered with Qt 5.9, and later.

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

  • The Android Command-line 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 you are using the SDK Tools 26.x or below, the JDK 8 is required. Versions higher than 8 might cause issues for the Android SDK tools.

    Читайте также:  Window android sdk manager

    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 version NDK version Toolchain
    Qt 5.14.0 or later Qt 5.13.2 or later Qt 5.12.6 or later NDK r20b or r21 android-clang
    Qt 5.12.0 to 5.12.5 Qt 5.13.0 to 5.13.1 NDK r19c android-clang
    Qt 5.11 and earlier NDK r10e GCC toolchain

    Note: Qt 5.14.0 and 5.14.1 with NDK r21 have a bug fixed at QTBUG-81461.

    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.

    Installing the Android SDK Essentials

    After downloading and unpacking the Commandline SDK Tools, use the sdkmanager command line tool to install the essential packages:

    Android Studio or the Qt Creator’s SDK Manager UI can also be used to install the essential SDK packages.

    To use the Android Emulator, install it by entering:

    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:

    After the package installation is complete, install the driver from /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:

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

    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.

    В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

    Источник

    Qt Documentation

    Contents

    You can download the Qt 5 sources from the Downloads page. For more information, visit the Getting Started with Qt page.

    Qt for Android has some requirements that are described in more detail in Getting Started with Qt for Android.

    Installing the Android SDK and NDK on Linux

    On Linux, you can install the Android SDK and NDK in one of two ways:

    Scripted Installation

    For any Debian-based Linux, use the following command:

    If you require openjdk, add default-jdk-headless to the command above.

    It’s recommended to install the NDK using sdkmanager, with the following commands:

    Manual Installation

    1. Download Android Studio from https://developer.android.com/studio/index.html.
    2. Open Android Studio and run the SDK Manager tool from Tools > Android > SDK Manager. If this toolbar isn’t visible, you can enable it from the View menu: select Toolbar.
    3. Download the Android NDK from https://developer.android.com/tools/sdk/ndk/index.html.

    Note: As of Qt 5.12, Android NDK r18 is required and gcc toolchains are no longer supported.

    Ensure that the NDK supports the API level you’re targeting. To verify, check your path_to_NDK/platforms directory.

    Note: As of Qt 5.13, any API level >= 21 is sufficient.

    Install a JDK with a version of 1.6 or newer from https://www.oracle.com/technetwork/java/javase/downloads/index.html. Alternatively, you can use OpenJDK.

    Building Qt for Android on Linux

    1. 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: $XDG_DATA_HOME/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 $HOME/.qt-license . If you prefer a different location or file name, you need to set the QT_LICENSE_FILE environment variable to the respective file path.
    2. Next, unpack the archive. If you have the qt-everywhere-opensource-src-%VERSION%.tar.gz package, type the following commands at a command line prompt:

    This creates the /tmp/qt-everywhere-opensource-src-%VERSION% directory containing the files from the archive. We only support the GNU version of the tar archiving utility; also known as gtar on some systems.

    Configure the JAVA_HOME environment variable. You need to set it and add it to your PATH ; preferably at the end of

    You may provide the -android-abis parameter to limit the Android ABIs targeted, such as armeabi-v7a, arm64-v8a, x86, or x86_64:

    If the parameter is not specified, Qt is built for all supported ABIs.

    To build the parts of Qt you have now configured run the following command. nproc is optional, representing the number of parallel jobs your system can do.

    If you haven’t used the —prefix configure option, the installation is placed under /usr/local/Qt- . In Debian/Ubuntu, you should prefix the make command with the sudo command.

    Installing the Android SDK and NDK on Windows

    Note: Currently, it is not possible to use Microsoft’s compilers to build the Windows host tools for Qt Android.

    Step 1: Setting up the Development Environment

    1. Install the latest Perl from http://strawberryperl.com. Then, select a destination folder, also known as PERL_ROOT .
    2. Set up the MinGW toolchain by downloading a pre-built Qt package for MinGW, and then add it to your PATH , for example: C:\dev\Qt\Tools\mingw730_64\bin .
    3. Install the latest JDK from https://www.oracle.com/technetwork/java/javase/downloads/index.html. Then, add the to PATH . Alternatively, if you’ve installed Android Studio, you can use the JDK that’s included in your installation’s jre folder.
    4. Install the Android NDK, r18b, from https://developer.android.com/tools/sdk/ndk/index.html. Extract it to .
    5. Install the latest Android SDK (tools only) from http://developer.android.com/sdk/index.html. Run the Android SDK Manager and install the latest version of «SDK Platform», «Google APIs», and «build-tools» in .
    6. Open the cmd.exe window and verify that:
      • where gcc.exe lists .exe first before

    .exe.

  • where mingw32-make.exe lists -make.exe first.
  • where javac.exe lists first.
  • Add the following environment variables:

    Depending on which NDK you have downloaded, add its path:

    Building Qt for Android on Windows

    • 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: %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 %USERPROFILE%\.qt-license . If you prefer a different location or file name, you need to set the QT_LICENSE_FILE environment variable to the respective file path.
    • Next, unpack the archive. Uncompress the files into the directory in which you want Qt installed, for example: C:\Qt\%VERSION% . This install path must not contain any spaces or Windows-specific file system characters.
    • Run the following command to configure Qt:

    is optional, representing the number of parallel jobs your system can do.

    Now, to install Qt, run the following command:

    В© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

    Источник

    Читайте также:  Adguard для андроид перестал блокировать рекламу
  • Оцените статью