Configuring Qt Gradle Plugin
The plugin needs to know where certain parts of the Qt toolchain are. In the <yourappname>/gradle.properties
file, you need to define paths for the plugin.
Note: You can also define them in the <yourappname>/app/build.gradle(.kts)
file inside a QtBuild block, but this has been deprecated and will be removed in the future.
Plugins path
Inside the plugins block, include the plugin ID and version.
plugins { id("org.qtproject.qt.gradleplugin") version("1.+") }
plugins { id 'org.qtproject.qt.gradleplugin' version '1.+' }
Dependency chain
The plugin automatically adds itself as a dependency to the default assembleDebug and assembleRelease tasks. However, when using custom product flavors, the plugin cannot know the names of the flavors, so you'll need to add them manually. For example, for a flavor named "core", add the dependency manually as shown.
android { ... applicationVariants.all { if (name == "coreDebug") { preBuildProvider.dependsOn("QtBuildTask") } } ... }
android { ... applicationVariants.configureEach { if (name == "coreDebug") { preBuildProvider.get().dependsOn "QtBuildTask" } } ... }
Define the properties as shown.
QtPath
Qt path for version 6.8.0 or newer where the Qt version you want to build against is installed:
qt.path=/home/username/Qt/
// Deprecated. Use gradle.properties instead QtBuild { ... qtPath = file("/home/username/Qt/6.8.0") ... }
// Deprecated. Use gradle.properties instead QtBuild { ... qtPath file('/home/username/Qt/6.8.0') ... }
QML project directory
Add the path to the QML project directory:
qt.projectPath=../qmlapp
// Deprecated. Use gradle.properties instead QtBuild { ... projectPath = file("../qmlapp") ... }
// Deprecated. Use gradle.properties instead QtBuild { ... projectPath = file('../qmlapp') ... }
Other properties are optional and explained below:
Optional: Qt ABI directory
By default, this is not defined, and Multi-ABIs will be built. If this path is defined, then a build will be done for that kit ABI only.
qt.abiPath=/home/username/qt/build/your-qt-kit
// Deprecated. Use gradle.properties instead QtBuild { ... qtKitDir = file("/home/username/qt/build/your-qt-kit") ... }
// Deprecated. Use gradle.properties instead QtBuild { ... qtKitDir = file('/home/username/qt/build/your-qt-kit') ... }
Optional: Extra CMake arguments
For example:
qt.extraCMakeArguments=-DCMAKE_BUILD_TYPE=Release,-DANDROID_NDK_ROOT=/opt/android/ndk/26.1.10909125
// Deprecated. Use gradle.properties instead QtBuild { ... setExtraCMakeArguments("-DCMAKE_BUILD_TYPE=Release", "-DANDROID_NDK_ROOT=/opt/android/ndk/26.1.10909125") ... }
// Deprecated. Use gradle.properties instead QtBuild { ... extraCMakeArguments = ['-DCMAKE_BUILD_TYPE=Release', '-DANDROID_NDK_ROOT=/opt/android/ndk/26.1.10909125'] ... }
Optional: ninjaPath
If you haven't installed Ninja from the Qt Maintenance Tool and its location is not defined in your system path, you can provide the path as follows:
qt.ninjaPath=C:\Qt\Tools\Ninja
// Deprecated. Use gradle.properties instead QtBuild { ... ninjaPath = "C:\Qt\Tools\Ninja" ... }
// Deprecated. Use gradle.properties instead QtBuild { ... ninjaPath = 'C:\Qt\Tools\Ninja' ... }
© 2025 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.