Freitag, 13. Dezember 2013

[Qt5, Android] Setting up Qt 5.2 for Android

I guess I won't need much words as most things can be seen in the pictures.
I hope it works for you as simple as for me.
Have fun!



I got the online installer from qt-project.org/downloads named: qt-linux-opensource-1.5.0-x64-online.run
Download and run it.



It can grab some older Qt versions. As we don't need those we don't check them.
If you have a ARMv5 device be sure to set the cross.
Most real devices won't be x86 so you normally don't need it. But it is good if you are testing on a virtual device. Because we will do that later it's checked here.





We need to setup the Android configuration.
(In case you already have a Qt and/or Android setup and have some configuration problems you might wanna check/remove/backup configurations and folders from Android, Qt and Trolltech from hidden places like ~/.config/… , ~/.local/share/… , ~/… )
You'll get to the next screen via menu: Tools → Options

They say they need the SDK and the NDK.
You'll get those here:
ADT-Bundle: http://developer.android.com/sdk/index.html
NDK: http://developer.android.com/tools/sdk/ndk/index.html
There is a SDK only version. I tried it but Qt Creator said that it would miss something. So you really should use the ADT-Bundle.

We will use a virtual device.
Currently there is non.
Start the Android AVD Manager.

Under Tools → Manage SDK you should check if all needed packages are installed.
For me I was not having the x86 image of Android. So I checked it.





After that I created a New virtual device.
Using the x86 ABI I will get hardware acceleration: http://developer.android.com/tools/devices/emulator.html#acceleration
That makes using the virtual device much more pleasant.

The new virtual device will also show up in the Qt Creator Options.

With those things set up we can check the Build & Run settings.
All needed configurations should be found automatically. Normally you should not need to manually add something yourself.





Now that is all set up we can create a little project to test if it will work.



Be sure that all of your desired targets are checked.
You can also add targets later.


In the Qt Creator, in the lower left, above the play button, there might be a computer icon or one of an Android dude, there you can select your current desired target platform. Android x86 it should be now.


Push the play button.
You will be greeted by a dialog to choose your device.
In this case we have just one that is shown in the compatible devices category.
That is what we want.

The Android virtual device will open.
In the background in Qt Creator you will see that the project is deploying.
Wait.
Wait.
Wait until it is done.
It might take a while.
After it finished your first Android app should open up looking like this:

If you had selected an ARMv7 target it would look like this:
In that case your virtual device is incompatible. Either change your target to Android x86 or create an Android ARMv7 virtual device.

Use the AVD manager for creating new virtual devices. It gives you more options and more control.


Have fun with your new set up!