All posts by gennon

Getting started with Enginio on Windows

If your application ever needs a persistent storage on a server or if you need to share data between lots of users or that data is changed often and the user really needs the latest and best data, well then using cloud storage of some kind can really be helpful.

So why Enginio, why not one of the others? Well, if you are using Qt, then it is super easy to implement the connection to the Enginio cloud and make use of its API. I have been working a good deal with Windows Azure, and it is really powerful, but it is more work to implement in a Qt Client than using Enginio.

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. Create an Engionio account

Its free!

https://dashboard.engin.io/#register

Then create an empty backend With a name of your Choice:

Create new backend

You will then see the Dashboard that will look something like this:

Dashboard

2. Download all the necessary files

!IMPORTANT! : Do not run any downloads yet, we will do that later, just download the installers.

First off you need Qt, at the time of writing the latest Version is 5.1.1:

http://qt-project.org/downloads

I would get Qt Online Installer for Windows (13 MB), because then I can get all the packages I need. Do not run the installer yet, we will do that later.

You also need OpenSSL installed on your computer since Enginio is using https for communications between client and server. You can find the binaries at: http://slproweb.com/products/Win32OpenSSL.html

Now for the Choice: 32-bit or 64-bit?

32: Win32 OpenSSL v1.0.1e Light

64: Win64 OpenSSL v1.0.1e Light

You will most likely do fine with 32-bit even on 64-bit system (I have not tested, but if you do, please let me know). I chose the 64-bit version.

You will, most likely, need the Visual C++ redistributables as well.

32: Visual C++ 2008 Redistributables

64: Visual C++ 2008 Redistributables (x64)

This choice between 32 and 64 bit is important, because this will dictate which versions of the other SW you need to download and install.

Now download the Enginio package from the Enginio dashboard.

Enginio Packages

I downloaded the Windows MSVC2012 x86_64 package due to two reasons:

1. I chose the 64-bit option above.

2. MSVC2012 is better than MSVC2010 😀

Since Enginio do not have any MinGW packages, we need to download MS Visual Studio 2012 Express. I chose the Express for Desktop Version. I hope they will add MinGW support to Enginio soon. If you have Mac or Linux this is of course not needed.

http://www.microsoft.com/visualstudio/eng/downloads#d-express-windows-desktop

3. Install software

You can start by installing Visual Studio Express, it should not take that long. You do not need to register (yet) or even start it up after install. You might need to restart the computer after install is done.

Next step is to run the Visual C++ 2008 Redistributable.

Next is the OpenSSL. Select “Windows system Directory” when you get the question for where to copy OpenSSL DLLs.

OpenSSL

Next is Qt and I usually put it in C:\Qt\ and these are the packages I install:

Qt Install

Not everything is needed for you, but I like to have these options for different settings.

Now, sit back and relax, take a cup of coffee or watch some telly, this gonna take a few minutes.

Next is installing the Enginio package. Now you will need to locate the folder where you have your qmake.exe file.

Enginio install

Rest is just Next, Next, Next.

4. Test out Enginio

Follow this: https://engin.io/documentation/qt/enginio-qml.html

Or

Start Qt Creator and create a New Project Qt Quick 2 Application (Built-in Types), name it whatever you want.

Make sure you check the MSVC2012 64-bit Project.

New Project

Now in the main.qml you will Write:


import QtQuick 2.0
import Enginio 1.0

Rectangle {
width: 360
height: 360
Text {
text: qsTr(“Hello World”)
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}

Enginio{
id: client
backendId: “123456789abcdef”
backendSecret: “123456789abcdef”

Component.onCompleted: {
var city = {
objectType: “objects.city”,
name: “Helsinki”,
population: 606000
};
client.create(city);

}
}
}

Just remember to pick your backendId and backendSecret from your Enginio Dashboard.

When you run it you should automatically create a New Object (a city Object) and it should be uploaded to the cloud. Go to your Dashboard and you should see the result.

Object View

5. Conclusion

That was getting started With Enginio, but I will try to make another post later with some more Enginio Magic.

Deploy Qt apps to Android using Qt 5.1

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

JDK (64-bit):  http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.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)

Qt 5.1 RC1: http://download.qt-project.org/development_releases/qt/5.1/5.1.0-rc1/

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.

Advanced System Settings
Advanced System Settings

Press the Environment Variables and there you should add a new System Variable:

Java Home
Java Home

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.

Android folder
Android development folder.

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:

C:\Program Files\Java\jdk1.7.0_21\bin;D:\android\sdk\tools;D:\android\sdk\platform-tools

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.

Qt Install
Qt Install

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:

Android SDK Manager
Android SDK Manager

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.

Android SDK Installer
Android SDK Installer

Now start Qt Creator and do not create a new project. Navigate to Tools -> Options -> Android and fill in the correct values:

Qt Android Settings
Qt Android Settings

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.

cd c:\

adb

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).

Android Targets
Android Targets

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.

Anyway….

Navigate to Projects -> Android for arm kit -> Run Settings -> Package Configurations

Package Configurations
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.

AndroidManifest.xml
AndroidManifest.xml

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:

adb devices

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!

/Gen