Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt on Android studio

Tags:

c++

android

qt

Using Qt creator, I complied MyLib.so, MyLibQt.so (compiled for android). MyLib is wrapper for using MyLibQt. In MyLibQt I have such lines

if (!QApplication::instance())
{
   g_bCleanUpInstance = true;
   new QApplication(argc, argv);
}

At Android Studio I added these libs to project (jniLibs). The lib has been successfully added to apk, it has been compiled. The problem is: when I try call method from MyLib, using previous lines of code, I get exception:

A/MyLibQt.dll: (null):0 ((null)): This application failed to start because it could not find or load the Qt platform plugin "android"

I added to jniLibs libqtforandroid.so, but it didn't helped. So, my question is: how to resolve it?

like image 231
Andrey Samoilov Avatar asked Dec 29 '25 08:12

Andrey Samoilov


1 Answers

Sorry for so late answer. Root cause of the issue was not so obvious. Qt plugin for Android requires function main() in your custom library. If the plugin doesn't find the function, the plugin throws exception and the plugin will not correctly loaded.

It was about Qt5.4- 5.7. I don't know how it is now but can suggest that there is same situation.

like image 191
Andrey Samoilov Avatar answered Dec 31 '25 22:12

Andrey Samoilov