Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unknown module in .pro file - cannot build app with androidextras module included

I am working on some Qt/QML app which will be deployed to Android OS. Now, I need module androidextras but if I put androidextras inside my .pro file as follows

QT += qml quick widgets sql core bluetooth printsupport androidextras

and I rerun qmake, I get following error:

Project ERROR: Unknown module(s) in QT: androidextras

I also tried to open and run the example project Qt Notifier but the same error occurs so that I cannot build either my app or the example, which should have worked out of the box.

I am using KUbuntu 15.04 with gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13) compiler and Desktop Qt 5.5.0 GCC 64bit Qt version. How do I build this androidextras module? I have Android arm v7 kit installed as you can see from the Maintenance Tool screenshot:

enter image description here

I've recompiled whole Qt with clear && ./configure -opensource -confirm-license -verbose -cups -plugin-sql-mysql -android-sdk /opt/android-sdk-linux -android-ndk /opt/android-ndk-r10d && make && make install, set up Qt version and Qt Kit in QtCreator, changed build kit and still same error pops up. Why?

like image 692
KernelPanic Avatar asked Sep 25 '15 09:09

KernelPanic


1 Answers

Extras modules are meant to provide additional functions specific to a certain platform and thus available only on that platform. It could be the support to the badge number on iOS apps, the support to Windows jump lists or some utility functions to convert from a type to the corresponding platform native type (e.g. QPixmap to CGImageRef, again in Mac extras).

There exist four extras modules - Win, Mac/iOS, X11, Android - and as long as you compile for the specific chosen platform against the specific kit, everything is fine. And it's also automatic, for desktop environment: your host machine is always your target machine.

Mobile kits are instead used to cross-compile from a certain (desktop) host machine to another (mobile) target machine. In this settings you can easily (and erroneously) compile platform specific code with the wrong kit.

Generally speaking, you should put platform specific modules/code inside conditionals to ensure that it is compiled only against the specific kit for which they are available. That's especially true for software which must be compiled both for desktop and mobile platforms or across different desktop platforms. Conditional in .pro file could look like this:

android: QT += androidextras
mac: QT += macextras
// ...other platform specific and platform independent  settings

See this answer for an android .pro example file which includes also manifest specific settings.

The same approach should be followed in code, i.e. check the OS and conditionally compile the platform code. For instance a multi-platform implementation of a function could look like this:

if defined(Q_OS_ANDROID)
#include <QtAndroid>
#include <QAndroidJniObject>
#endif

// other code...

void YourClass::function()
{
#if defined(Q_OS_ANDROID)
// platform code
#elif defined(Q_OS_WIN)

#endif
}        

See for instance this answer for a complete Android example or this other answer for some useful iOS specific keywords.

like image 96
BaCaRoZzo Avatar answered Nov 16 '22 04:11

BaCaRoZzo