Previous command will cleanup any older configuration, and then will configure & build (for debugging) Qt framework, it will take a while until everything is finished.
To complete the job, you have to push qt libs to your device.
QtCreator can do this job for you, if you check Deploy local qt libs option (Projects->Android (run tab)->Deploy configurations->Deploy local qt libs) check the picture below.
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 thenecessitas framework provides you scripts you can use to manage your Qt for Android projects. Both ways are explained in the subchapters.
Using Qt Creator
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
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).
Choose the Qt Version
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.
Android version targeted
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.
The Projects View
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.
The Run ViewPackage Configurations
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.
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.
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.
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:
Use devices qt libs
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.
Deploy local qt libs
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
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 theMinistro .apk
on the Google Market or from here.
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.
Debugging Qt apps for Android
Debugging multi-thread applications on Android is possible starting with android 2.2.1 version (if you are using AVD you have to choose android 2.3 or later), for more informations please check NDK-GDB.html file located into android-ndk-folder/docs.
Replace gdb version of the Android Native Development Kit
For a seamless debugging experience you should replace the default android-ndk gdb with 7.1.x or 7.2 (download).
You can simply overwrite the /pathTo/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/folder
with one of the arm-linux-androideabi-4.4.3 folder
present in the tar archive.
Change Android target Sdk
Debugging native multi threaded applications on Android (Qt applications are multi threaded) is supported only since the android-10 API level, so please choose this level or a higher one if you want to be able to debug your applications.
1. Changing Android target Sdk to one which supports native multi threaded applications debugging
Rebuild your application
Please take care that you have to rebuild the application in debug mode, if you want to be able to debug it. Click on the project source tree and rebuild everything before trying to launch in debug, it will not be done automatically.
2. Clean & Rebuild everything in debug mode