Qt Tools for Android Studio

The Qt Tools for Android Studio plugin allows you to create new or import existing Qt QML projects to an Android Studio project. Therefore, you can embed QML elements, such as a 3D view, inside your Android project without installing or using Qt Creator. The plugin requires Qt 6.7 or later. Please have a look here for all the prerequisites needed. 

To install the plugin, go to the JetBrains marketplace page and install it directly or download the plugin jar file. See the docs for instructions on installing the plugin with the jar file.  

The plugin needs to know where certain parts of the Qt toolchain are. Go to File -> Settings, expand the Build, Execution, Deployment section, and select Qt. If you didn't change the location of the Qt installation during installation, it should be automatically filled in; otherwise, please provide the location manually.  

In the first field, you need to provide the path to qt-cmake. You can find this file in [Qt Folder Path]/<qt version>/android_<architecture>/bin. For example, C:\Qt\6.7.0\android_arm64_v8a\bin\qt-cmake.bat (Note that you need to select qt-cmake.bat for Windows and qt-cmake for Linux and Mac).  

We will import the QML in Java-Based Android Projects simple example project.  

In Android Studio, go to File -> Open, or select Open from the Android Studio welcome screen. Navigate to the example project, select the “qml_in_java_based_android_project” folder, and press OK. 

Once the project opens, go to File -> New -> Import Qt Project... and select the “qml_in_android_view” folder from the example project. 

After importing, if your configuration has a problem, an error popup will appear, as shown. 

Click on the “Configure” button to open the Qt settings page.  

Now, you can see your project directory structure in the project view on the left.  

 

Pressing the Run button will build the Qt project, copy all the dependencies, and modify the build.gradle file, and run the Android app on the emulator or a physical device, depending on which you are using. 


Blog Topics:

Comments