Qt for Android!
12/22/2012 § Leave a comment
Its been months since my last post, but I’ve been so busy! Among doing my best to nurture a new romance and rounding up jobs its been incredibly hectic. Finally rounding up a really great job to do GUI programming using Qt, I’ve attacked this job like a dog after meat. I love Qt programming, its really great. I’ve spent the last few months learning more and more about this fantastic framework and I love it. I’ve always felt that messaging paradigms were the right key to distributed programming and the Qt development team has done a remarkable job porting their great framework from Linux to Windows.
Qt has been sold again, I guess from Nokia to Digia, before that it was its own company under the name “Trolltech, LLC”, I think. Obviously its been acquired a few times because the people who bought it knew it was developing a great product. Nokia’s recent troubles probably prompted the recent sale to Digia. Doesn’t matter who has it as long as they don’t mess with what’s working.
As well as being able to create great UI’s with this full-featured framework KDE has just trotted out a “pre-beta” (kind of) version of Qt for Android called “Necessitas”. What their relationship with Digia is I’m not sure, probably a licensing/legal thing as Qt has an open source/community version maintained by a semi-separate org, I think. I’m not sure how all the relationships are intertwined, I just know there are a number of people involved in creating a really great framework.
I really wanted to do some android development so last year I went through the great effort of installing the Google Android Development Kit and for me- it was hell on earth. Maybe I’m stupid, but I just found the whole thing really messy and hard to use. I’ve never been a big eclipse fan, but I use it when I must, and you must if you want to get up and running with the ADT quickly. Well, quickly is a relative term. After several weeks of installing things and adjusting settings I finally produced a fart app. The whole process was so painful however I really kind of dropped my enthusiasm for using THAT to create android apps.
In the meantime however I was popping out code for a desktop project with wild abandon. After months of struggling to wrangle android code with ADT/Eclipse I was actually having fun coding again. If I could get Qt on android… wow! They have it!
Its still in pre-beta release, as I said earlier, but it is usable. That doesn’t mean set up is a snap either. Let me give you the steps I used to get going and save you the trouble;
I installed this on my MacBook Pro Windows machine as my trusty Mint Linux box is too under powered to run the Android Virtual Device with any speed.
- Install the Oracle JDK and set up your JAVA_HOME variable and put %JAVA_HOME%/bin in your userspace path. 32 or 64 bit versions, it doesn’t appear to matter.
- Down load the Necessitas installer and run it. Take all default options. I don’t particularly care to have Necessitas in my home directory but I decided not to test fate on this one. If you have it installed and running elsewhere please drop me a line.
- This might be an unnecessary step, but I followed the advice of one poster and installed the latest ant build system on top of the one provided by the necessitas installer.
- BEFORE DOING ANYTHING ELSE run the adb.exe in ..\necessitas\android-sdk\platform-tools and let it download and install all the android kits you think you will be using. I installed everything it would let me. You also need to delete some old libs and replace them with new ones, just use the provided buttons. The whole process took at least two hours. Brew some coffee, play some Warcraft, whatever your poison.
- Locate the AVD Manager that should now be in ..\necessitas\android-sdk (it won’t appear here until you do the previous step) and set up at least one AVD, I recommend one at ADK level 2.3, I think that’s API level 10.
- Download the Ministro II runtime kit and the MinistroConfigurationTool II.apk from the same place to the same directory as the adb.exe in ..\necessitas\android-sdk\platform-tools
- Open a cmd shell in THAT directory and execute ‘adb install “Ministro II.apk”, and do the same for the configuration tool.
- Important Create a new project, don’t need to code anything, and then select the “Projects” tab on the left side of the IDE. Select the “Run” button next to the “add kit” and “Manage Kits…” button, and change the “Android target Configurations” under “Run Settings” from whatever it is to “android-10”.
- Run your project. You should see the Qt “Q” logo against a dark back ground, then a message about Ministro needing some libraries. Then you should see this;
- This will go on for a number of minutes as Ministro downloads whatever it needs. This is a one-time deal for all your Qt apps. You will need to install Ministro on any device you want to run your Qt app on, obviously its the runtime manager for Qt apps on Android.
You should see your app in the emulator’s screen. Start coding your award-winning app with Qt. Its a pain in the ass to set up but I found it a bit less of a pain compared to app development with Google’s adt, which would be an on-going torture. Should improve and a lot of these steps should be unnecessary as Necessitas matures.