Configure Qt for Android
Surely, one day, most apps on the Android platform will be built with Qt - the UI of those apps with their beautiful Qml scripting language.
Xml is ugly, mixing that with Java’s syntax and handing it over to developers as the only way to design UIs for your device is inhumane.
In case you already know about Qt, good, if not…, oh, you might want to share our joy and our enthusiasm with, the technology that built WhatsApp (because it powered Nokia), that also powers Adobe products including Photoshop and Premiere pro. Qt is known as the necessary framework for c++ developers, now it is available for Java and python as well.
Getting Qt up and running for Android should be easy, except for only one place where software updates posses a threat to the smooth running of affairs.
Prerequisites
1. Install all of android, the Android studio, there is no way around it. It’s I think, around 4GB to install. Download it here. The process of installing it is very easy, you won’t have problems. Be sure to install at least one kit as well.
2. You need to have at least Qt Creator installed. Install it here if you don’t already have it installed.
3. Here is where the whole hiccup is; You need to download an earlier version of the Android NDK, the latest version (r20) doesn’t really work well with Qt 5.13 or earlier, so use an earlier version, if you do this, you won’t have any problem with your configuration. I used Revision 19(b or c doesn’t matter, you’ll understand when you head over to their website), get it here.
You should install it in your android sdk folder, under either the name ndk-bundle or the ndk revision name, if you are going to have multiples revisions of it. If you don’t know where your android Sdk is located you should probably look at C:\Users\{username}\AppData\Local\Android\Sdk for windows users, it is definitely something equivalent on Mac and on Linux or other operating systems.
It is very important that you remember where you installed your NDK, if you didn’t install it via Android Studio, because if you did, Android Studio will give it to you.
Search for Paths
You will need to find the paths to the Java Development Kit, Android SDK and the Android NDK. There is a simple way to find these.
Getting them from Android Studio
a. Open Android Studio
b. Create a new project (dummy project).
c. Wait for the project to sync
c. Click File > Project structure > Sdk Location or File > Other Settings > Default project structure. There you will see all three paths; Sdk, Jdk, and Ndk.
Configure Qt
- Open Qt Creator.
- Click Tools > Options > Devices > Android
- Put in the paths we got from android studio for the; JDK location, Android SDK location and Android NDK location fields.
- You should see a green check mark for all the three fields.
Test Build
- Click the welcome Tab.
- Look through the Examples for Analog Clock Window Example or another Example with an android tag.
- Click on it
- On the configure project page, make sure all your android kits are checked, you will have to find out which ones work well for your device.
- Click configure project
- In the build section, click the button above the build and run buttons > select any of the Android kits.
- Wait for the Build and Run buttons to become enabled.
- Click either the Build or Run button. Build — if you do not have a device or emulator ready, Run — if you have any handy.
Conclusion
I think c++ developers should use Qml to write their UIs for Android. Qt supports sensors and Bluetooth for android, you have access to Firebase. Oh, the ease and Joy of building UIs with Qml.