Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76038

UnsatisfiedLinkError when manually registering functions via JNI_OnLoad

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.3
    • QPA
    • None
    • Android 6
    • Android

    Description

      For example, we have an application with Java Service. Both the main activity and the Service linked to the same `.so` library, but the Service has an additional arguments to the `.so` library at the `AndroidManifest.xml`.

      So, when the main application and the Service are closed and we run the Java Service by external trigger, for example by phone call we see the following actions:

       

      1. The Java Service is started
      2. It loads the `.so` library
      3. The `JNI_OnLoad()` function is called at the `.so` library and we register Java native methods by using `JNIEnv::RegisterNatives()` method
      4. The `main()` function is called at the `.so` library
      5. After several seconds we call a native method from Java side
      6. We get the `java.lang.UnsatisfiedLinkError: No implementation found for...` error

       

      But when we call the `System.loadLibrary()` method from Java side we see the following actions:

       

      1. The Java Service is started
      2. It loads the `.so` library
      3. The `JNI_OnLoad()` function is called at the `.so` library and we register Java native methods by using `JNIEnv::RegisterNatives()` method
      4. The `main()` function is called at the `.so` library
      5. We call the `System.loadLibrary()` method from Java side
      6. The `JNI_OnLoad()` function is called at the `.so` library and we register Java native methods by using `JNIEnv::RegisterNatives()` method
      7. The `main()` function is NOT called at the `.so` library. And it is a problem.
      8. After several seconds we call a native method from Java side
      9. The native method is called at C++ side, but because the `main()` function was not called the `qApp` is null and we do not have Qt main event loop here. And it is a problem.

       

      Related bug report: https://bugreports.qt.io/browse/QTBUG-68813

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            taipan BogDan Vatra
            ildar Gilmanov Ildar
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes