Qt Apps on Android! Part One : <3 is in the Air :)

Have you loved two tangentially apart technologies at the same time? Its like holding one girl’s hand while you woo another one ;) Yeah something like that is the case with me. To my girl – “Its OK sweety, I’m just talking about Qt and Android :)”

There must have been a time when you would have thought, “Oh God, I wish I could just port all these apps I run on my desktop to my new android phone.” Or maybe you are one of hose who say, “I wish I could use my Android cell to prototype my new Qt based embedded device that I am making. It’d be something cool to show to those black shoes, red tie morons in the conference room.”

The Necessitas project comes to your aid guys. I shall be writing a short tutorial series on creating small Qt app like these :

in the speediest of ways and port it to your device. This part will consist of setting up the tools necessary for Qt application development on Android

Necessitas

Also known as Android Lighthouse project, this is the individually developed port of Qt for Android. Necessitas comes with a modified Qt Creator IDE for building, deploying and even debugging your applications directly for your Android device. You will be amazed to see the ease with which you can develop and debug your apps. Say thanks to BogDan Vatra and those unsung heroes who have brought this to you. Now lets begin.

Get Necessitas SDK

Get the Necessitas 0.3 online installer from here. I however downloaded the 0.1.1 version available as an offline install which serves the purpose well. Its available in old versions directory. The installation is pretty straight forward. Just run the installer and make sure that you install the SDK in /opt/necessitas. You may have to make your /opt 777 for sometime and then revert back to 755 once the installation is over.  The SDK mainly consists of the cross compiler for android on ARM and lots of cross compiled ARM libs for Qt. I have mentioned in previous posts how to do all that manually but here, its all ready for you :) Once the installation is over, you will get a Necesitas Qt Creator in your applications. This is almost same as your traditional Qt Creator IDE. We shall move on to configure it now.

Configure Qt Creator

Requirements :

  • Install ant if required by yum install ant
  • Check whether you have JDK with java -version
  • Get Android SDK from here
  • Get Android NDK from here

Step 1

Extract the SDK and NDK at some locations and start Necessitas Qt Creator/Qt Creator for Android and go to Tools>Options. Click Qt4 tab and Add a new qmake path. Give this new qmake path from /opt/necessitas/Android/<qtversion>/bin/qmake This qmake will make the projects and makefiles cross-compile ready. Give some name to it – maybe Qt for Android

Step 2

Now that you have the new Qt setup, Click the Android tab on the left and specify the SDK and NDK target and set proper toolchain as shown below. Also set the ant location and hit Apply

If you are not having any Android device, then create a AVD to test your app. Lastly, some configuration is also required on your device.

Step 3

Now, we have almost everything ready for development on our device, however to run a Qt app we need libraries on the target device. For this, there are two options. Either while developing application, an option to use local Qt libs can be selected or a nifty tool called Ministro can be used. Ministro is an android application that can be downloaded from the Android market. This application performs a one time download of Qt libs from the net on the device as required by the application you have created. In a simple application mostly it will do a mostly 8Mb install of QtCore and QtGui modules.

The next post will describe how to create a small digital clock app (as shown above) using the Qt Creator, something about putting Style Sheets in Qt apps and then get it on your device! Keep experimenting.

Source : http://sourceforge.net/p/necessitas/home/necessitas/

About these ads

2 comments

  1. Hi ,
    Thanx for ur great efforts.But I am trying to run app on emulator as well as on my android device .I even installed ministro for emulator and on the device also.But the problem coming is app is building successfully on qt creator but while running on emulator it demands for extra libraries.But when I start installing them it stops working.So I need ur help in this regard what I should I do exactly to run the app on emulator and device.

    1. Ministro gets libs as required and downloads and sets them up for you. I It may take some time. If it crashes, then the issue is different. You may need to google a bit. I am sure the answer is out there (Hint : check https://groups.google.com/forum/#!forum/android-qt) Also, with Qt 5.1 and 5.2, official support for android is coming soon. If its not for fun and serious development, you may want to wait for release 5.2. Have a look at : http://blog.qt.digia.com/blog/2013/03/13/preview-of-qt-5-for-android/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s