Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QApplication crashes on constructor from JNI (Android)
Qt 6.11 is out! See what's new in the release blog

QApplication crashes on constructor from JNI (Android)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 4 Posters 3.8k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sqrella
    wrote on last edited by
    #1

    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:

    libgnustl_shared.so
    libplugins_platforms_android_libqtforandroid.so
    libQt5AndroidExtras.so
    libQt5Core.so
    libQt5Gui.so
    libQt5Multimedia.so
    libQt5Network.so
    libQt5Widgets.so

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

    Have you any suggestions?
    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you share the stack trace ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • S Offline
        S Offline
        Sqrella
        wrote on last edited by
        #3

        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/com.example.gb.myndkapplication2 A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 17576 (ndkapplication2)

        Do you mean this?
        0_1502089078952_StackTrace.png

        Thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • G Offline
            G Offline
            Greg Perez
            wrote on last edited by
            #5

            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.

            A 1 Reply Last reply
            0
            • G Greg Perez

              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.

              A Offline
              A Offline
              ambershark
              wrote on last edited by
              #6

              @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.

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved