Details
-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
5.12.1
Description
Hi,
As the title suggests, I have been trying to run native c++ code from a QtService.
As per the documentation, I have added the service in the Android Manifest and provided the necessary metadatas. I've also added an -service argument to identify if the library is being instantiated from the main application or the QtService (I have the same .so file for Main Application and Service).
Also in main function I logged the arguments to check if the library is loaded correctly from the QtService as follows :
int main(int argc, char* argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); qDebug() << QCoreApplication::arguments(); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
When the main application starts, I am getting the log as expected.
But when I start the QtService, there is no log which suggests the library does not get loaded.
Attaching the manifest, qtservice, and the main.cpp file for reference. Also attaching the sample project.
To test things out, I tried manually loading the library from the Java code using System.loadLibrary()
System.loadLibrary() was able to load the library and I was able to call a native function from the Java code, but I was unable to instantiate a QCoreApplication / QAndroidService.
If I instantiate a QCoreApplication / QAndroidService I get an error :
W : QApplication::exec: Please instantiate the QApplication object first W : QWindowSystemInterface::flushWindowSystemEvents() invoked after QGuiApplication destruction, discarding 2 events. F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 19212 (qtMainLoopThrea)