Qt Gradle Plugin 1.0 Released

Qt Gradle Plugin 1.0 (QtGP) build tool has been released. You can include it in your Android builds from Maven Central.

Bridging Android and Qt Builds

In 6.7 and earlier versions, Qt for Android could build Android Applications and Android App Bundle packages. Now, in 6.8, it's possible to select the "aar" target for a Qt application project and build the Android Archived Library (AAR) package. QtGP uses this to help developers to seamlessly add a Qt project to the Gradle build system of their Android project. All CMake configuration and build steps to create the AAR happen under the hood, and the resulting AAR gets added as a dependency to the module that applies the plugin.

You can add QtGP in your app/build.gradle file, by adding QtGP as a dependency.

plugins {
    id("org.qtproject.qt.gradleplugin") version("1.+")
}

Next, you need to specify qtPath and projectPath properties inside the QtBuild block:

QtBuild {
    // Qt installation directory
    qtPath = file("~/Qt/6.8.0")
    
    // QML project directory
    projectPath = file("../qmlapp")
}

The latest release of Qt Tools for Android Studio helps you add QtGP to your project and with creating or importing QML projects. When the properties are added and an Android build is triggered, QtGP runs QtBuildTask, which will build an AAR bundle of the Qt project specified in the QtBuild block. This AAR will provide the needed Qt libraries for your Android application. QtGP supports Qt 6.8 and above, which will be released shortly.

Currently, if QtGP is added, it will run when the Android build is triggered, but it can also be initiated in a couple of other ways:

  • From the Command line:
./gradlew QtBuildTask
 
  • Android Studio using Qt Tools for Android Studio: Main menu -> Build -> Build Qt Project

QtBuildTaskFromQtTAS

  • Android Studio: Right side Gradle -> app -> qtproject -> QtBuildTask

QtBuildFromAndroidStudio

QtBuildTask will use CMake for configuring and Ninja to build the Qt project. The build output can be found under build/qt_generated. For more detailed information on using Qt Gradle plugin, refer to our official documentation.

What is coming next?

As a next step, we are working on making build times shorter by having incremental build support in the QtBuildTask. We would love to hear what you would like to see added to the plugin. You can track work progress and provide feedback at bugreports.qt.io.


Blog Topics:

Comments