User:Joger/Building Qt Multimedia for Android: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
Line 28: Line 28:
Run provisioning script from "K:\qt\android\qt6\coin\provisioning\common\windows\install-mingw.ps1" as administrator. This installs MINGW into C:\MINGW_PATH.
Run provisioning script from "K:\qt\android\qt6\coin\provisioning\common\windows\install-mingw.ps1" as administrator. This installs MINGW into C:\MINGW_PATH.


== Building Qt for Android on Windows ==
== Creating Qt Host Build ==
Main build root Android: K:\qt\android\android
Follow steps in https://doc.qt.io/qt-6/android-building.html to create a host build.


Follow steps in https://doc.qt.io/qt-6/android-building.html to create a host build. Note that only the host_tools target must be built.
Clone Qt source code
K:\qt\Android> git clone <nowiki>git://code.qt.io/qt/qt5.git</nowiki> qt6
Initialize Qt submodules and configure the host build
K:\qt\Android\host> ..\qt6\configure -developer-build -nomake tests -nomake examples -submodules qtmultimedia -init-submodules -codereview-username <gerrit username>
Build the host build
K:\qt\Android\host> cmake --build . --target host_tools --parallel


Main build directory for Qt Multimedia on Android: D:\qt\build\androidmultimedia
== Building Qt for Android on Windows ==
Enable the MINGW compiler suite
set MINGW_ROOT=C:\MINGW_PATH\mingw64\bin
set PATH=%MINGW_ROOT%;%PATH%
Configure Qt for cross compile with Android using the host host build from K:\qt\android\host\qtbase.
K:\qt\Android\android> ..\qt6\configure -debug -developer-build -qt-host-path K:\qt\android\host\qtbase -android-abis arm64-v8a -android-sdk C:\utils\android\ -android-ndk C:\utils\android\ndk\26.1.10909125\ -submodules qtmultimedia
  -nomake tests -nomake examples && ninja.exe
Build
K:\qt\Android\android> ninja


Configure Qt Multimedia for Android <blockquote>cmake-DCMAKE_TOOLCHAIN_FILE=D:\qt\build\android\qtbase\lib\cmake\qt6\qt.toolchain.cmake -G Ninja  -DQT_USE_ORIGINAL_COMPILER=ON -DQT_BUILD_TESTS=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF D:/qt/qt6/qtmultimedia & ninja</blockquote>
== Configure QtMultimedia module for cross compiling with Android ==
When working with QtMultimedia, it is convenient to configure a separate build just for this submodule. This makes configuring and rebuilding faster as long as we only touch code in this submodule.
K:\qt\android\qtmultimedia> ..\android\qtbase\bin\qt-configure-module.bat ..\qt6\qtmultimedia -- -DQT_BUILD_TESTS=ON -DQT_BUILD_EXAMPLES=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF -DQT_BUILD_EXAMPLES_BY_DEFAULT=OFF


== Importing Qt Multimedia build into QtCreator ==
== Importing Qt Multimedia build into QtCreator ==

Revision as of 13:30, 11 August 2024

About this page

On this page I describe how I build Qt Multimedia for Android on Windows.

See also Qt documentation at Qt for Android - Building from Source | Qt 6.7

My build setup

  • OS: Windows 11 with dev drive mounted on K: (Using a dev drive makes builds faster when using Windows Defender antivirus)
  • Qt source tree: K:\qt\android\qt6
  • Build directory main Android build: K:\qt\android\android
  • Main (host) build for dev branch: K:\qt\android\host
  • Visual Studio 2022 (MSVC)
  • Don't have perl in path as it can cause hard to understand build failures
  • Have cmake in path

Setting up Android SDK/NDK and JAVA

  1. Install Qt Creator with Android option using Qt Maintenance Tool
  2. In Creator preferences, install Adoptium JDK (C:\Program Files\Eclipse Adoptium\jdk-17.0.10.7-hotspot)
  3. Android SDK location: C:\Utils\Android
  4. Select Android NDK 26.1.10909125 and make default
  5. Oppenssl location: C:\Utils\Android\android_openssl
  6. Verify Android settings:

Android settings 26.png

  1. Add Android device for ABI x86_64, OS Version 13.0 ("Tiramisu") (SDK 33)

Android Emulator.png

Install MINGW

Run provisioning script from "K:\qt\android\qt6\coin\provisioning\common\windows\install-mingw.ps1" as administrator. This installs MINGW into C:\MINGW_PATH.

Creating Qt Host Build

Follow steps in https://doc.qt.io/qt-6/android-building.html to create a host build.

Clone Qt source code

K:\qt\Android> git clone git://code.qt.io/qt/qt5.git qt6

Initialize Qt submodules and configure the host build

K:\qt\Android\host> ..\qt6\configure -developer-build -nomake tests -nomake examples -submodules qtmultimedia -init-submodules -codereview-username <gerrit username>

Build the host build

K:\qt\Android\host> cmake --build . --target host_tools --parallel

Building Qt for Android on Windows

Enable the MINGW compiler suite

set MINGW_ROOT=C:\MINGW_PATH\mingw64\bin
set PATH=%MINGW_ROOT%;%PATH%

Configure Qt for cross compile with Android using the host host build from K:\qt\android\host\qtbase.

K:\qt\Android\android> ..\qt6\configure -debug -developer-build -qt-host-path K:\qt\android\host\qtbase -android-abis arm64-v8a -android-sdk C:\utils\android\ -android-ndk C:\utils\android\ndk\26.1.10909125\ -submodules qtmultimedia
 -nomake tests -nomake examples && ninja.exe

Build

K:\qt\Android\android> ninja

Configure QtMultimedia module for cross compiling with Android

When working with QtMultimedia, it is convenient to configure a separate build just for this submodule. This makes configuring and rebuilding faster as long as we only touch code in this submodule.

K:\qt\android\qtmultimedia> ..\android\qtbase\bin\qt-configure-module.bat ..\qt6\qtmultimedia -- -DQT_BUILD_TESTS=ON -DQT_BUILD_EXAMPLES=ON -DQT_BUILD_TESTS_BY_DEFAULT=OFF -DQT_BUILD_EXAMPLES_BY_DEFAULT=OFF

Importing Qt Multimedia build into QtCreator

  1. Open QtMultimedia CMakeLists.txt from D:\qt\qt6\qtmultimedia
  2. Deselect all kits
  3. Import build from D:\qt\build\androidmultimedia
    • This creates a Android Qt 6.8.0 (android) Clang x86_64 kit
    • Configure is run automatically again
  4. Select a test to be built (tst_qmediadevices) and choose a corresponding emulator in project build settings for Android kit
  5. Build target tst_qmediadevices
  6. Observe error message:

19:15:12: The process "C:\Program Files\CMake\bin\cmake.exe" exited normally.

19:15:12: Starting: "D:\qt\build\dev\qtbase\bin\androiddeployqt.exe" --input D:/qt/build/androidmultimedia/tests/auto/unit/multimedia/qmediadevices/android-tst_qmediadevices-deployment-settings.json --output D:/qt/build/androidmultimedia/tests/auto/unit/multimedia/qmediadevices/android-build --android-platform android-33 --jdk "C:/Program Files/Eclipse Adoptium/jdk-17.0.10.7-hotspot" --gradle

Cannot find application binary in build dir D:/qt/build/androidmultimedia/tests/auto/unit/multimedia/qmediadevices/android-build//libs/x86_64/libtst_qmediadevices_x86_64.so.

19:15:12: The process "D:\qt\build\dev\qtbase\bin\androiddeployqt.exe" exited with code 2.

Error while building/deploying project QtMultimedia (kit: Android Qt 6.8.0 (android) Clang x86_64)

When executing step "Build Android APK"

19:15:12: Elapsed time: 01:05.