UPDATE: This was initially made for Qt 5.1 RC1, but it also works for Qt 5.1 final.
UPDATE 2: Here is a video by Василий Колесников that explains it all:
OK, so I was having some issues (probably most of them) when I decided to try to deploy a Qt application to my Android device. And as a reminder to myself, and probably as a help for others, I have decided to make a small guide for how to do this step by step.
0. Computer setup
I am using Windows 8 Pro 64-bit as my OS. But I guess most of the stuff will be the same regardless if using Mac or any Linux OS. Let me know of any major differences and I will write it down.
1. Download all the necessary files
Android SDK (64 bit): http://developer.android.com/sdk/index.html
Android NDK (64-bit): http://developer.android.com/tools/sdk/ndk/index.html
I guess OpenJDK will work as well on Linux: http://openjdk.java.net/install/
Ant: http://ant.apache.org/bindownload.cgi (grab the zip archive)
I got the qt-windows-opensource-5.1.0-rc1-android-x86-win32-offline.exe version.
Qt 5.1 Final: http://qt-project.org/downloads
I got the Qt 5.1.0 for Android (Windows 32-bit, 716 MB) version
2. Install software
Start with installing JDK. On my computer the default location is: C:\Program Files\Java\jdk1.7.0_21
Now you need to create a system environment variable for other programs to know about this location.
Get into System “Control Panel – > System and Security -> System”. On the top-left- side you will have several links, one is called Advanced System Settings.
Press the Environment Variables and there you should add a new System Variable:
The Variable value should be the folder where you have installed JDK.
IMPORTANT: Make sure you write this one correctly and make sure you have the “\” at the end. And do not add the \bin folder, that will result in in an error when running Ant later on.
I made a folder on my drive: D:\android where I place all the android related stuff.
That required some renaming of the NDK folder and Ant folder, but that does not impact the development environment at all.
Now go back to the Environment Variables and locate the Path System Variable and add the following paths:
IMPORTANT: Make sure that these folders points to YOUR installation and folder setup. They will most likely differ from the above. The separator “;” between each path is very important.
For Qt I installed in the default folder: C:\Qt\Qt 5.1.0 and installed everything.
Next, Next next…
IMPORTANT: Restart your computer! This makes sure that System variables are saved and probably a hundred other things that are important.
3. Android SDK
Start Eclipse: Should be D:\android\eclipse\eclipse.exe or wherever you placed the Android SDK.
If you have any issues starting Eclipse it will most likely be that JDK is not installed or that you did not add JDK to your Path system variable.
Now press the Android SDK Manager button:
Qt for Android only support Android API 10 and above so make sure you have at least one of those installed. And make sure that your device support it as well, if you plan to deploy your app to the device. Also make sure you have the Google USB Driver installed.
Now start Qt Creator and do not create a new project. Navigate to Tools -> Options -> Android and fill in the correct values:
Now, Apply and quit Qt Creator and restart your computer! Just to be safe!
4. Create your Qt Android Project
First start up a shell (cmd.exe) and see if you have Android Debug Bridge working.
If you get a lot of output from the adb command then it is installed and adb is in your Path environment.
Now start Qt Creator and create a new Qt Quick 2 Application (Built-in Elements) project. Name it Test.
For target you should now have several Android targets as well. Check of Android for arm (GCC 4.7, Qt 5.1.0).
Now there seems to be a bug if you try to create a project on another drive than where Qt is installed. For me I have Qt on C:\ but I usually have my projects on D:\. That does not seem to work in my version of Qt 5.1.0 RC1 using Qt Creator 2.7.2 at least. It worked fine with Qt 5.0.2 and Qt Creator 2.7.0.
Navigate to Projects -> Android for arm kit -> Run Settings -> Package Configurations
Make sure that your settings are as the above image. If it is not, then you might need to restart your computer or click a blank Android target SDK drop-down and select which API to use. If your Package name is just “.Test” then you need to edit the AndroidManifest.xml file which is in your project folder and in the android folder.
Locate the manifest tag and the package value at the top and change it to something similar as “com.company.test” and it should be fine.
5. Deploy to device
Connect your Android device to your computer using USB cable and make sure you have enabled it to debug: http://developer.android.com/tools/device.html
To see if it working you could use the shell and adb:
This will list all the devices connected to your computer.
Now the last step is just to press Play (and Pray)!
Are you lucky, then the app will be launching on your device in a few seconds.
And then we are done! I hope this little guide can help anyone, and that you enjoy your Qt for Android hacking!