QApplication crashes on constructor from JNI (Android)

  • Hi all,

    I've created a library that uses Qt Widgets; if called from non-Qt application, it creates an instance of QApplication.
    Everything works fine on Windows and linux, from C app and also from a Java app (using JNA).
    It works also in Android if called from a Qt app.
    Now I'm trying to get it to work on Android calling it from a Java application made with Android Studio, using JNI.
    At first I had a problem finding the platform plugin, but solved setting the QT_QPA_PLATFORM_PLUGIN_PATH.
    But when I create QApplication object, it crashes on constructor, with SIGSEGV in libc.
    I don't think that is a problem with argc and argv parameters, because If I create a QCoreApplication instead it doesn't crash, but I need widgets...
    I am using Qt 5.6.2, but tried also 5.8 and 5.9.1, same result.
    And NDK r10e, but also with r14b is the same.

    In the Android Studio project, in the folder jniLibs\armeabi-v7a, I've put the following libs together with mine:

    I have copied them from the APK that the working Qt app generates...

    Have you any suggestions?

  • Lifetime Qt Champion


    Can you share the stack trace ?

  • Hi,

    sorry, I'm completely new to Android Studio...
    In the logcat I see only this line:
    08-07 08:51:41.810 17576-17576/ A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 17576 (ndkapplication2)

    Do you mean this?


  • Lifetime Qt Champion

    Based on this thread, it seems that other people had some success using Qt classes from an Android application.

    However, I don't know whether the GUI part can be used that way. I think you should check the Qt Android mailing list to find out whether it's currently supported. You'll find there Qt's Android port developers/maintainers. This forum is more user oriented.

  • Hi @Sqrella . Were you able to track down the issue? I am experience the same crash in QT 5.9 and I'm unable figure out the root problem.

  • Moderators

    @Greg-Perez Well based on his error findClass is returning a nullptr and then it is being referenced causing a crash.

    So whatever findClass is trying to find, it isn't. But nobody checks the return and assumes it was successful and tries to use it.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.