GUIDE: How to install Qt Components for Android (Thanks to Koying)

3,014 views
Skip to first unread message

faenil

unread,
Dec 20, 2011, 6:24:46 AM12/20/11
to andro...@googlegroups.com
Hi guys,

after I spent some time trying to get Qt Components to work,

I'm posting my experience here :) I hope it will be helpful for the community :) I started from Koying's guide but since I got stuck with that one, I'm writing a new one ;)

First of all, BIG THANKS to Koying who worked on the components and shared them with the community :)

Step by step guide (refer to http://groups.google.com/group/android-qt/browse_thread/thread/8a8dad69042a28af for the first guide written by Koying himself):

1) Download this package  http://dl.dropbox.com/u/7264433/QuickComponentsAndroidarmv7.zip and copy "imports" and "plugins" folders to the "qml" directory in your project's folder

2) Add the following to your .pro file:
android { 
    qmlcomponents.source = qml/imports 
    qmlcomponents.target = / 
    DEPLOYMENTFOLDERS += qmlcomponents 
    qmlplugins.files = \ 
        qml/plugins/libandroidplugin_1_1.so \ 
        qml/plugins/libqtcomponentsplugin_1_1.so 
        x86 { 
            qmlplugins.path = /libs/x86 
        } else: armeabi-v7a { 
            qmlplugins.path = /libs/armeabi-v7a 
        } else { 
            qmlplugins.path = /libs/armeabi 
        } 
    INSTALLS += qmlplugins 


3) Add the following code to your main.cpp:

#ifdef Q_OS_ANDROID 
    viewer->addImportPath("/imports/"); 
    viewer->engine()->addPluginPath(QDir::homePath()+"/../lib"); 
#endif 

NOTE: the following code should work on Alpha 4: 
#ifdef Q_OS_ANDROID 
    viewer->addImportPath("/imports/"); 
    viewer->engine()->addPluginPath(QApplication::applicationDirPath()+"/lib"); 
#endif 

4) In Necessitas Qt Creator, go to Projects->Run Settings->Package Configurations (hit on "details")->Libraries (it's one of the tabs) 
and put a tick on the QtSystemInfo library

5) Deploy the package as you usually do via QtCreator and enjoy Qt Componeny by Koying :)

Koying

unread,
Dec 20, 2011, 8:27:55 AM12/20/11
to andro...@googlegroups.com
Thanks for the guide ;)

faenil

unread,
Dec 20, 2011, 8:38:35 AM12/20/11
to andro...@googlegroups.com
thanks for the components! :D

Jonny

unread,
Dec 20, 2011, 9:50:53 AM12/20/11
to android-qt
Thanks to both of you!
Also add the following includes to main.cpp:
#include <QDir>
#include <QDeclarativeEngine>

Its still not working for me though...
The components are getting installed now but as soon as the app starts
it crashes instantly with no messages or output of any kind. If I rem
out the com.nokia.android 1.1 import it will load up no problem so its
crashing when it access the plugin, I figure...
Do I need to add any permissions or anything else? Currently I have
android.permission.INTERNET and
android.permission.WRITE_EXTERNAL_STORAGE set.
THANKS!
Jon

Koying

unread,
Dec 20, 2011, 10:09:33 AM12/20/11
to andro...@googlegroups.com
Are you sure you compile your app for armv7.
This typically occurs when there is a discrepancy between the app architecture and one of its libs.

Jonny

unread,
Dec 20, 2011, 4:51:49 PM12/20/11
to android-qt
Good point!
I now realize I dont currently have anything to test armv7 builds
with. ;)
I am assuming that the components and so files from your git
repository are armv5?
I replaced the imports and plugins in my test app from the git
repository here: https://gitorious.org/~koying/qt-components/android-qt-components
I build it for armv5, and its still just crashes immediately. If i
disable the components import, it builds and deploys fine...
Thanks!
Jon

Jonny

unread,
Dec 20, 2011, 11:17:26 PM12/20/11
to android-qt
Got it! I must have had something messed up with all my mucking about,
I reinstalled everything fresh and they loaded right up!
Thanks again!!
Cheers,
Jon

mingw android

unread,
Dec 21, 2011, 12:28:35 AM12/21/11
to andro...@googlegroups.com

You can test armv7a with the emulator so long as you use api 14.

Jonny

unread,
Dec 21, 2011, 9:50:47 AM12/21/11
to android-qt
Thanks mingw! I will have to try it out...

I am having an issue with the selectionDialog component, it seems its
not finding the libqtcomponentsplugin_1_1.so when I try to access it.
I verified the plugin is where it should be as well as the components,
not sure what the issue may be. Has anyone else had success with the
selectionDialog component?
Here is the output to necessitas from the device when I try to access
the selectionDialog:

W/Qt (16589): file:///qml/ECalc/grounding.qml:177:21: Type
SelectionDialog unavailable
W/Qt (16589): file:///imports/com/nokia/android.1.1/SelectionDialog.qml:44:1:
Type CommonDialog unavailable
W/Qt (16589): file:///imports/com/nokia/android.1.1/CommonDialog.qml:67:9:
Type ToolButton unavailable
W/Qt (16589): file:///imports/com/nokia/android.1.1/ToolButton.qml:42:1:
plugin cannot be loaded for module "Qt.labs.components": Cannot load
library /imports/Qt/labs/components.1.1/libqtcomponentsplugin_1_1.so:
(Cannot load library: load_library[1118]: Library '/imports/Qt/labs/
components.1.1/libqtcomponentsplugin_1_1.so' not found)

I started to trace it out after typing the above, if you rem out all
references to checkable in the toolButton.qml the selectionDialog
works fine...
Have to go to work now, will pick this back up later... ;)
Cheers,
Jon

Jonny

unread,
Dec 21, 2011, 5:58:46 PM12/21/11
to android-qt
I found a small error in ScrollBar.qml from the git repo. On line 100
is, target: symbian I changed that to, target: android and all is well
again.
Cheers,
Jon

harri

unread,
Jan 4, 2012, 4:54:53 AM1/4/12
to andro...@googlegroups.com
Looks like

<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>

also needs to be added to AndroidManifest.xml, otherwise you get:

I/Qt JAVA ( 5438): Can't load '/data/data/org.kde.necessitas.ministro/files/qt/lib/libQtSystemInfo.so'

I/Qt JAVA ( 5438): java.lang.SecurityException: Requires DISABLE_KEYGUARD permission


But the next stumbling block for me was:

W/Qt ( 6695): file:///imports/com/nokia/android.1.1/PageStackWindow.qml:95:9: Cannot assign to non-existent property "platformInverted"

W/Qt ( 6695): platformInverted: root.platformInverted


I tried to clone the component repo, but that fails with:


git clone https://gitorious.org/~koying/qt-components/android-qt-components
Cloning into android-qt-components...
fatal: https://gitorious.org/~koying/qt-components/android-qt-components/info/refs not found: did you run git update-server-info on the server?





Maciej Płaza

unread,
Jan 11, 2012, 6:50:13 AM1/11/12
to andro...@googlegroups.com
2012/1/4 harri <hpas...@gmail.com>:
Hi.

Can I use Qt Components with ARMv5?

Regards.
--
Maciej Płaza.

Harri Pasanen

unread,
Jan 11, 2012, 7:17:39 AM1/11/12
to andro...@googlegroups.com

On 01/11/2012 12:50 PM, Maciej P�aza wrote:
>
> Hi.
>
> Can I use Qt Components with ARMv5?
>
> Regards.


Presumably you'd need to compile them yourself then.

git clone git://gitorious.org/~koying/qt-components/android-qt-components

to check out.

Jonny

unread,
Jan 11, 2012, 7:27:27 AM1/11/12
to android-qt
Yep, they work fine as is for armv5 from Koyings repo . Just copy the
plugins and imports folder into the qml folder and add the lines to
the pro and main.cpp as described above, they work great.
Cheers,
Jon

On Jan 11, 6:50 am, Maciej Płaza <plaza.mac...@gmail.com> wrote:
> 2012/1/4 harri <hpasa...@gmail.com>:
>
>
>
>
>
>
>
> > Looks like
>
> > <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
>
> > also needs to be added to AndroidManifest.xml, otherwise you get:
>
> > I/Qt JAVA ( 5438): Can't load
> > '/data/data/org.kde.necessitas.ministro/files/qt/lib/libQtSystemInfo.so'
>
> > I/Qt JAVA ( 5438): java.lang.SecurityException: Requires DISABLE_KEYGUARD
> > permission
>
> > But the next stumbling block for me was:
>
> > W/Qt ( 6695):
> > file:///imports/com/nokia/android.1.1/PageStackWindow.qml:95:9: Cannot
> > assign to non-existent property "platformInverted"
>
> > W/Qt ( 6695): platformInverted: root.platformInverted
>
> > I tried to clone the component repo, but that fails with:
>
> > git clonehttps://gitorious.org/~koying/qt-components/android-qt-components
> > Cloning into android-qt-components...
> > fatal:
> >https://gitorious.org/~koying/qt-components/android-qt-components/inf...

Maciej Płaza

unread,
Jan 11, 2012, 11:47:00 AM1/11/12
to andro...@googlegroups.com

Thanks guys. Do you have compiled libs for ARMv5? I have some problems
with my own compilation (QtMobility and QFeedback).

Regards.
--
Maciej Płaza.

Peter Staab

unread,
Jun 11, 2012, 4:21:29 AM6/11/12
to andro...@googlegroups.com
Hi,

I am getting this error when I try to use Qt Components with Necessitas Alpha 3:
##
qrc:/qml/TestQMLAndroid/main.qml:4:1: module "com.nokia.android" is not installed
##

I am using the arm5 binaries from here and changed the project files accordingly: http://redmine.semperpax.com/projects/qt-components-android

Attached is the complete Qt Creator project. Why are the Qt Component libraries not correctly loaded?

Regards,
TestQMLAndroid.zip

Peter Staab

unread,
Jun 11, 2012, 5:32:34 AM6/11/12
to andro...@googlegroups.com
More testing revealed that the problem occurs on Windows 7 only. Linux works fine. There seems to be a glitch when deploying on Win7.

danielcbit

unread,
Jul 23, 2012, 5:50:49 PM7/23/12
to andro...@googlegroups.com
I know this topic is a little bit old but I was wondering how can I deploy the necessary libs and qml files when using qrc in my applications.

Right now, the examples I've encountered (http://redmine.semperpax.com/projects/qt-components-android) use the default sample application structure created by Necessitas's QtCreator which is terrible.

I want to deploy apps to Android that use qrc to store qml files. That, for what I have seen, break the ways presented on how to deploy the libs and qml's used Qt Componenets for android.

And does somebody has any information about these components being shipped with necessitas in a upcoming release?

Thanks!

Daniel Bittencourt

unread,
Aug 9, 2012, 11:07:21 AM8/9/12
to andro...@googlegroups.com, chrisa...@gmail.com
Answering my own question I developer a simple process to include the Qt Components to any project

The files and instructions can be found here: http://dl.dropbox.com/u/6994819/qtcomponents_android.tar.gz

If you have any questions, please contact me.

AlterX

unread,
Sep 16, 2012, 6:53:53 PM9/16/12
to andro...@googlegroups.com
I'm trying qt-components on necessitas Alpha 4; all went ok, but I am receiving plugin problem:

assets:/qml/ProvaAndroid/main.qml:2:1: module "com.nokia.android" is not installed


I'm trying all advices here...

Mihajlo Savic

unread,
Sep 25, 2012, 3:03:50 PM9/25/12
to andro...@googlegroups.com, chrisa...@gmail.com
Hi,

Would it be possible to tar gzip one project that is tested to work? Nothing special, just one project with any symbian component (tab bar or whatever)?

I would really appreciate it since this is not working either (module "com.nokia.android" is not installed)

Cheers,
Mihajlo

ho Soon Fatt

unread,
Feb 26, 2014, 8:38:13 AM2/26/14
to andro...@googlegroups.com
Now that Qt5 is out so is this still valid?

Ayberk Özgür

unread,
Sep 4, 2014, 8:03:34 AM9/4/14
to andro...@googlegroups.com
We found out that with Qt 5.3 we had to deploy our QML plugin/component to the QT_INSTALL_QML directory in order for an Android Qt application to be able to use it. This directory is /opt/Qt/5.3/android_armv7/qml in our case. Our QML plugin .pro file looks something like:

TEMPLATE = lib
TARGET = prova
QT += qml quick multimedia
CONFIG += qt plugin c++11 console
CONFIG -= android_install
TARGET = $$qtLibraryTarget($$TARGET)
uri = com.mycompany.qmlcomponents

# Input
SOURCES += \
    src1.cpp \
    src2.cpp

HEADERS += \
    src1.h \
    src2.h

##The below is generated automatically by Qt Creator when you create a new "Qt Quick 2 Extension Plugin" project for Android

#Copies the qmldir file to the build directory
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
    copy_qmldir.target = $$OUT_PWD/qmldir
    copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
    copy_qmldir.commands = $(COPY_FILE) \"$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)\"
    QMAKE_EXTRA_TARGETS += copy_qmldir
    PRE_TARGETDEPS += $$copy_qmldir.target
}

#Copies the qmldir file and the built plugin .so to the QT_INSTALL_QML directory
qmldir.files = qmldir
unix {
    installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
    qmldir.path = $$installPath
    target.path = $$installPath
    INSTALLS += target qmldir
}

Our qmldir (in the plugin source tree root) file is:
module com.mycompany.qmlcomponents
plugin prova

In the project that uses this plugin, the .pro file:

TEMPLATE = app

QT += qml quick widgets multimedia

CONFIG+= console
SOURCES += main.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(deployment.pri)

contains(ANDROID_TARGET_ARCH,armeabi-v7a) {
    ANDROID_EXTRA_LIBS = \
        /opt/Qt/5.3/android_armv7/qml/com/mycompany/qmlcomponents/libprova.so
}

We don't actually know if the inclusion of the extra libprova.so is necessary. It's most probably not. 

The main.cpp looks like:

#include <QApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[]){
    QApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
    return app.exec();
}

The way we build and deploy the plugin is to `qmake` (from the android-armv7 toolchain of Qt), then `make install`. It installs the qmldir file and the plugin .so to the QT_INSTALL_QML directory. 

The way we build and deploy the project that uses the plugin is to `qmake` (again, from the android-armv7 toolchain of Qt), then `make install INSTALL_ROOT=.` (installs to build directory), then run `androiddeployqt`. The last command creates the Android project structure with the qmldirs in assets/ and libraries in libs/ and bundles the whole thing in an apk via `ant`. For the details of this procedure, refer to http://qt-project.org/wiki/Android

In short, we were only able to get our QML plugin recognized inside an Android project by putting it inside the private Qt qml directory. 

Traxx

unread,
Sep 4, 2014, 8:30:31 AM9/4/14
to andro...@googlegroups.com
Thank you very much. This really help clear things up. I didn't expect any answer after so many months. Right now I decided to focus on BlackBerry bb10 first before moving to android. Even in BlackBerry version is still use symbian component to retain the identity. Thank you again.
Reply all
Reply to author
Forward
0 new messages