Reading Time : Less than 20 minutes
After a long effort I made Necessitas working on my machine. I strongly believe I should blog it at the right time. So lets start setting up the development environment with Necessitas. Necessitas provides a custom Qt-Creator release with Android stuff integrated. Even though you can build Qt-Creator and QMake yourself for this purpose, I would suggest you to use the installation script available for download. This article is based on Ubuntu 11.10 and ant version 1.8.4. Lets start creating a new folder for installing Necessitas.
sudo mkdir /opt/necessitas
sudo chmod -R 777 /opt/necessitas
So, we have created a folder in /opt and it is has necessary permissions. Now download the installer and save it under your home folder. Once it is made executable, you can run it.
sudo chmod a+x ~/Downloads/necessitas-<version>-online-sdk-installer-linux
You will be guided through a set of steps by the installer. When asked for installtion folder, choose /opt/necessitas. In the component selection page, you can choose to opt out unnecessary API version of Android SDK. This will reduce the download size.
Finally, press Install to begin the installation process. On a windows machine, I got an error message that the installer requires atleast 16GiB of space for temporary files. This might also be applicable to Linux. The installation process would take a few minutes (or even hours on slow speed Internet connections) to complete. Once the installation is complete, open the Qt-Create for Necessitas. Go to Tools > Options and switch to the Android tab, and set android SDK and NDK locations. In my case,
SDK Location : /opt/necessitas/android-sdk
NDK Location : /opt/necessitas/android-ndk-r6b
ANT Location : /usr/bin/ant
Now, click on the Start AVD Manager button, and create an AVD with atleast 1024MiB SD card and HVGA resolution. Finally Start the emulator you have created. Now, jump to the Qt4 tab in the Options window, and make it looking as same as in the following image (To see the image in full resolution, right click on it and select View Image)
Press OK to close the Options window. Close Necessitas Qt-Creator but leave the emulator running. Download the latest Ministro service package for Android from here. Once downloaded, open a terminal and issue the following command.
adb install <full path file name of the ministro apk>
Now, start Qt-Creator for Necessitas. Create a new project and select Qt - Mobile Application as the template. Remove the content of MainWindow::setOrientation() method since it contains some reference to Symbian. You will be greeted with the first class Qt GUI designer. Add a couple of widgets you would like to see on the screen. I have added a QLabel and QPushButton. Click the Run button on the left pane. Now check the emulator and you will see the Necessitas Library download message.
This is a one time process. The download wont happen again for another program which requires the exact same library. Once the library has been loaded, the application will start running. Take a look at my output.
Here in this article, we have not played anything with the source code. So, there will be no functionality at all. In the upcoming articles I would try to introduce more Necessitas stuff. But I hope this would be a great start for you with Necessitas. Also don’t forget to watch a much more professional video here.
//See you in the afterlife