In the previous post we have presented process of deploying an application on the iOS mobile platform. The deployment process was divided into two stages: building the application and putting it on the store. On Android, the process will look very much the same. The first stage is building the application on the selected operating system (Linux, Windows), and the next is publishing the application on the Google Store. In the case of the Android mobile platform, it is important to choose the system on which the application will be built. In this post we will show you how to build an Android application with Qt for Windows.
Building an Android application with Qt
At the beginning, you should prepare an environment that allows you to build Android applications on Windows. To do this, download the necessary dependencies that allow to make it. Before it, you have to download Qt installer from Qt official website and install it on your system. Then, install dependencies required to build the application:
– Android Software Development Kit Tools
– Java Development Kit
– Android Native Development Kit – package that allows you to create applications using C++
– Gradle – for building application packages (APK) and app bundles (AAB) for Android devices
Links to download all the necessary packages for the proper version of Qt for Android can be found by launching Qt Creator and then entering Tools, Options, Device, Android.
There is an arrow on the network on each path to replace items, for easy download. In the case of SDK, after it has been downloaded, the SDK Manager exits program and start to update data and download missing components. It should be ensured that we do not run out of elements such as: Android SDK Platform-Tools, Android SDK Build-Tools and Google USB Driver. If we have all the tools downloaded and set up correctly, we can try to compile our application. If you are using a physical device instead of simulator, remember to turn on USB debugging.
If your environment is correctly set up, you should find Kit definitions for at least installed Qt Android versions in the Kits section in the configuration dialog of Qt Creator. Building an application for the Android mobile platform is complicated, but with Qt it becomes much easier as Qt script carries out all the steps automatically. If you want to know what the steps for compiling and building an application package look like, please see this link:
If you want to build an application using the command line, you must refer to the documentation and read the steps to complete this process. All the steps are described at this link:
The last step is to build the application with Qt Creator. To do this, select appropriate compiler that we have defined earlier and press the green arrow, i.e., the Run button.
A modal window will appear with all available Android devices compatible with the compiler you are using listed. Select the appropriate equipment and click OK. At this point, a notification should appear on the phone regarding the installation of a new application via USB debugging. We grant installation permission, and we can fully enjoy your working Android application.
AndroidManifes.xml is a very important file in the project, because it gives detailed meta-information about your application. This information is used to customize the application package and is used by the target device to decide which features to enable, for example: default application orientation and so on. Also, it is used by the Google Play Store to retrieve version code information, device support, package name, and more.
The default file contains special parameters that Qt uses to configure the application and load all necessary libraries for Qt. Make sure all default parameters are set correctly before adjusting the file. This is necessary for the application to function properly. The Android manifest is used to define Android services and custom Android actions.
AAB and APK file
When building an Android application, you’ll be facing a myriad of different file formats and terminology. Particularly when exporting the final version of the application, you will see two main output formats. In this paragraph we will explain the difference between APK and AAB formats.
The more known format is that with the APK extension. It has been around for a long time and is the most commonly used format when building an application as it is suitable for direct installation on the device with Android system. The APK format is also used when debugging an application due to its installation speed.
AAB, which stands for Android Application Bundle, is a more recent format for Android distribution. The AAB format is newer than APK, it was introduced in 2018. App Bundles are publishing formats, whereas APK (Android application PacKage) is the packaging format which eventually will be installed on the device. This format became the official format for publishing Android apps.
Comparison of APK and App Bundle formats
– AAB format provides higher conversion rates than APK format
– AAB format provides faster downloads than APK format
– AAB format provides higher update rates than APK format
– AAB format provides lower uninstall time than the APK format
– AAB format provides 35% smaller size than the APK format
– AAB format should be used to avoid unnecessary copying of native libraries
Publishing to Google Play
If you want to publish your app on Google Store, you can do so by using Qt Creator. Most of the tasks required to finish publishing in the shop, especially packaging and deploying of the application, are handled by Qt Creator. Whenever you run the application using Qt Creator, an Android Application Package (APK) is created and deployed on the target of your choice (device or emulator). If you want to publish your application on Google Play you have to make several minor changes to packaging settings. The steps for publishing your app to Google Store are listed below.
1. Open your project with Qt Creator 4.11 or later choosing Release Build.
2. Select Projects > Build > Build Android APK > Create Templates to create Android package template files, such as AndroidManifest.xml, which is the main file of concern here.
3. Check for the following settings in AndroidManifest.xml:
– set Minimum required SDK to API 21 or later,
– set Application name and Application icon,
– verify if Permissions list has all of the required permissions,
– verify if Features list has the software or hardware features that your application depends on, such as GPS or NFC, etc.
4. Set up a keystore to sign your .apk file. You can create a new keystore if you do not have one.
5. Locate the generated package:
– For APK packages, the path is:
– For AAB packages, the path is:
6. Log into Google Play Developer Console and upload either, .apk or .aab files, along with a description and screen captures resembling the usage of your application.
Remember that if you want to submit application to Google Play, you need to create Google Play developer account and Google Wallet Merchant Center account before uploading files. The guide explaining how to add the application to the Google Store is also available at this link:
Process of deploying application to the Android mobile platform is simpler than with iOS, as the entire deployment process takes place in Qt Creator. The only difficulty is in installing all the necessary add-ons and configuring the runtime environment. In the case of Android, the deployment process can take place on different systems, it is not limited as in the case of iOS, where the deployment must take place on a computer with macOS. In the case of Android, all configuration is in Qt Creator, while iOS configuration is in XCode. Another great advantage is the possibility to add Android applications to the Google Store via Qt Creator. The process of adding an app to the store is very similar for both cases – it requires creating accounts and supplementing all the basic information about the application.
There are no comments so far