- Установка среды QtCreator для создания linux и android приложений
- Getting Started with Qt for Android
- Android Development Prerequisites
- Manually Installing the Prerequisites
- Java Development Kit (JDK)
- Android SDK Command Line Tools
- Android SDK
- Android NDK
- Emulator
- Platform Specific Configurations
- Testing Your Setup
- Qt for Android — Building from Source
- Prerequisites
- Windows
- Getting the Sources
- Configuring
- Architectures
- Advanced Configure Arguments
- Building
- Installing
Установка среды QtCreator для создания linux и android приложений
5. Заходим в Qt, открываем меню «Инструменты» — «Параметры» — «Андроид», указываем правильные пути, например:
Android SDK Location: /home/johnsmith/dev/android-sdk-linux
Android NDK Location: /home/johnsmith/dev/android-ndk-r8e
JDK Location: /usr/lib/jvm/java-6-openjdk-i386
6. Если хотите тестировать в живую, то подключите свой планшет к компьютеру и поставьте галочку Enable USB Debugging
8. ~/qt/android-sdk/tools$ ./android
жмем Unselect All
выбираем нужную версию Android, например 4.0
в ней отмечаем SDK Platform и ARM EABI v7a System Image
жмем Install packages
9. QtCreator — Инструменты — Параметры — Android — Управление AVD
Добавить
выбираем armeabi-v7a, остальное по вкусу, жмем ОК
10. В настройках сборки android создаем шаблоны
делаем иконки (48, 128, 512) android приложения на сайте http://makeappicon.com/
делаем файлы res/values/string.xml res/values-ru/string.xml
в них пишем название программы на русском и английском, а в manifest.xml пишем «@string/app_name» вместо имени
11. Открываем ~/qt/android-sdk/tools/ant/build.xml
в секции Other properties дописываем:
/build-tools/23.0.0-preview/aidl$»/>
/build-tools/23.0.0-preview/aapt$»/>
/build-tools/23.0.0-preview/dx$»/>
/build-tools/23.0.0-preview/zipalign$»/>
где «23.0.0-preview» — это реально существующая папка, если она у вас по другому называется, то измените эту часть строки
«$» используется только в windows, в linux нет
Getting Started with Qt for Android
The video below is a beginner’s guide to using the Qt for Android toolchain, including the Qt Creator IDE, to get you started developing Android apps.
The rest of this page has more detailed getting started information. To download and install Qt for Android, follow the instructions on the Getting Started with Qt page.
Android Development Prerequisites
- Java Development Kit (JDK) for Java development
- Android SDK Command Line Tools for managing dependencies required for developing with Qt for Android, including:
- Android SDK Platform
- Android SDK Platform Tools
- Android SDK Build Tools
- Android NDK
The easiest way to manage these dependencies is by using Qt Creator’s built in Android development setup. For more information, see Qt Creator: Specifying Android Device Settings.
Manually Installing the Prerequisites
If you prefer to manually install the prerequisites please follow these next steps.
Java Development Kit (JDK)
Qt for Android development requires JDK 11 or above, provided by any of the following supported distributions:
Please install your preferred JDK, and then make sure the JAVA_HOME environment variable is pointing to the location of the installed JDK.
sudo apt-get install openjdk-11-jdk export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
brew install openjdk@11 sudo ln -sfn "$(brew --prefix openjdk@11)/libexec/openjdk.jdk" "/Library/Java/JavaVirtualMachines/openjdk-11.jdk" export JAVA_HOME="$(/usr/libexec/java_home -v 11)"
Android SDK Command Line Tools
Install the latest version of the Android SDK Command Line Tools for your operating system, and verify that the installation succeeded by running the sdkmanager binary:
Then make sure the ANDROID_SDK_ROOT environment variable is pointing to the location of the installed command line tools.
brew install android-commandlinetool export ANDROID_SDK_ROOT="$(brew --prefix)/share/android-commandlinetools"
Android SDK
The required version of the Platform, Platform Tools, and Build Tools for 6.5 is 33.
To install all of these run the following command:
sdkmanager "platforms;android-31" "platform-tools" "build-tools;33.0.0"
Android NDK
The required version of the Android NDK for 6.5 is 25.1.8937393.
To install the NDK run the following command:
Then make sure the ANDROID_NDK_ROOT environment variable is pointing to the location of the installed NDK.
export ANDROID_NDK_ROOT="$(brew --prefix)/share/android-commandlinetools/ndk/23.1.7779620/"
Emulator
If you wish to use the Android Emulator, you can install it by running:
sdkmanager "emulator" "patcher;v4"
Platform Specific Configurations
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:
sdkmanager.bat "extras;google;usb_driver"
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
The following dependencies are needed for using tools such as adb or gdb which can be used by Qt Creator:
sudo apt-get install libstdc++6 libncurses5
To run the Android emulator, the following dependencies are also necessary:
sudo apt-get install libsdl1.2debian
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.
© 2023 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 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
Note: Qt for Android does not support building from source with Microsoft Visual C++ (MSVC).
Install the requirements, and set the PATH to include the newly installed binaries:
set MINGW_ROOT=\bin set PATH=%MINGW_ROOT%;%PATH%
To verify the installation, run:
The command should list mingw32-make.exe under the path 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
Qt 6 allows building Qt for Android from source code using CMake . Qt 6 keeps the same configure script from Qt 5. The main difference is that Qt for Android is dependent on a host Qt build, which means to build Qt for Android, you need to build Qt for the desktop platform used as a host (for example Linux, macOS, or Windows).
To configure Qt for Android, create a shadow build directory to keep the source directory clean:
And then run the configure script:
/configure -platform android-clang -prefix -android-ndk $ANDROID_NDK_ROOT -android-sdk $ANDROID_SDK_ROOT -qt-host-path
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.
Architectures
Qt for Android supports the following ABIs:
The following configurations are supported in this Qt release:
Distribution Architecture Compiler Notes Android 8.0 to Android 13 (API level 26 to API 33) armeabi-v7a , x86 , arm64-v8 , and x86_64 Clang 14.0.6 (NDK r25b) as provided by Google For JDK versions see Java Development Kit (JDK) Note: It’s recommended that Qt user apps use the same NDK r25b version used for building these official Qt for Android libraries. An NDK version more recent than r23b is required if building a project results in an error of missing the symbols for __emutls_get_address .
To choose the ABI to build for, use the -android-abis feature of the configure script.
Note: 6.5 does not yet support being built for multiple ABIs at the same time.
Advanced Configure Arguments
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:
-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 -prefix argument:
Qt Configure Options contains more information about the configure options.
Building
To build the configured Qt code, run the following command:
Installing
Now, to install Qt, run the following command:
On Unix based OSes you should prefix the install command with the sudo command.
If you haven’t provided the —prefix configure option, the installation is placed under /usr/local/Qt- .
© 2023 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.