There are multiple ways to develop Qt Applications for Android, the easiest one is to use the fabulous Qt Creator For Android enabling you to deploy, run and debug Qt and your Qt application on the device.
Although if you are more used to the CLI using an advanced text editor, or if you want to use another IDE the necessitas framework provides you scripts you can use to manage your Qt for Android projects. Both ways are explained in the subchapters.
Qt Creator is a first class IDE for developing Qt Applications with the different tools it provides. Developing a Qt Application for Android with the Qt Creator provided in the necessitas framework lets programmers be productive and enjoy Android application development in C++.
Create a new Qt C++ Project, this can either be a Qt Gui Project or a Qt Mobile Application (in this case you will have to remove the body of MainWindow::setOrientation generated by Qt Creator, which contains references to Qt For Symbian).
Once you have chosen the project name QtCreator will ask you which Qt version to use. It should propose by default those you configured: android-lighthouse-4.8.0 debug & android-lighthouse-4.8.0 release. Check them if they aren’t already selected and deselect any other Qt versions which are available.
When your project is created, you are almost done, you will just need to select which android version you are targeting and how you want to deploy the Qt Libs onto the device.
Click on the Projects view (the icon is located on the left hand side of the QtCreator window): Qt for Android Integration adds two views here: Build & Run which appear in a small box towards the top of the main window, clicking on Build or Run swaps between the Build and Run views within the Project View.
Select Run view and then by selecting Details at the side of Package Configurations you can select between the Manifest, Application, Permissions and Libraries tabs.
In the Manifest tab you can select which Android target SDK you want to use. This provides the different API levels which match specific Android versions. You can find more information about API levels and how they equate to the Android version here.
Note: android-4 API level is the only one which doesn’t support multitouch, so if your application needs multitouch you have to chose a higher one.
You can choose a Package name for your application, indeed the application is launched by an automatically generated java launcher, which will be packaged with your application in an .apk (more information about the .apk: Android Application Fundamentals), and an apk has to be in a package.
Figure 1. You can choose the Android target SDK (Android Level API) and the other Manifest information of you Android Qt application.
On the Application tab you can choose an icon for your application and set the application's name.
With the Permissions tab you can pick which permissions are needed for your application, so that the people installing it, will know what it will do, and that the Android OS will give your application access to the required features.
Figure 2. You can easily pick one of the existing Android permissions, or add yourself new ones if you are deploying for a specific Android OS.
The Libraries tab will offer you an automatic way to determine which Qt libraries you use! Or if needed let you select manually the Qt libraries and the external libraries you think your application needs. These entries will be used by the Ministro tool to determine which Qt libraries have to be downloaded.
Figure 3. This gives the Java Loader the list of required Qt Libraries and other prebundled libraries, that should get loaded with your application. It also provides to ministro the list of Qt Libraries required.
Also on the Run view you can set the Deploy Configurations, by selecting Details at the right hand side these are the different options you can choose between:
The Use devices qt libs option depends also on the Use local qt libs option. When Use local qt libs is unchecked your application will need the Ministro package to run. However if Use local qt libs is checked, Qt Creator will pass special parameters to the application, forcing it to use Qt libraries from the /data/local/qt path on the device.
The Deploy local qt libs option makes Qt Creator deploy qt libs found in the Qt SDK chosen (e.g. android-lighthouse-4.8.0). This option is useful when you hack on the Qt framework to test it.
This option automatically selects the Use local qt libs option. This option get automatically unchecked after Qt Creator pushes the Qt libs. This option can be checked every time you need to push your local Qt modifications. (In fact it has the same effect as the push_qt_libs.sh script, which can be found at the root of the Qt for Android Sdk). You do not need to check Deploy local qt libs to take advantage of the Use local qt libs option.
Install Ministro system option installs the Ministro package (actually it installs any .apk you select :) ) for you. It is useful when you try to test your application on Android Virtual Devices. You can get the Ministro .apk on the Google Market or from here.
Figure 4. The Deploy Configuration of the Projects Run View provides different ways to deploy Qt on the Android Virtual Devices following needs
This part will be added, as soon as we update the helper scripts for CLI development with Qt on Android.
You are done, you can now enjoy the development phase. :) You can build and run your application on the device. You will notice that the application output is forwarded to Qt Creator and that you can get interesting debugging information there, plus you can also set breakpoints.