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. Problem using context and JNI
Forum Updated to NodeBB v4.3 + New Features

Problem using context and JNI

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 3 Posters 1.8k Views 2 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.
  • D Offline
    D Offline
    Damalo_02
    wrote on last edited by
    #1

    Hello,

    I would like to do an Android app using FTDI Java library and Qt.
    Firstly, because I found easier to code in Java, I did my app on Android Studio and it works well.
    FTDI methods use application context as argument : 0_1556619455603_d6c28dfc-5c7b-4f83-a142-b7358398789d-image.png

    Now I'm trying to do the same app on Qt Creator.
    As a simple example, I'm just trying to call a Java method (that uses application context) from C++ using JNI.

    The problem is I'm getting this error and I don't know how to solve it :

    W/System.err(15479): java.lang.NoSuchMethodError: no static method "Lcom/ftdi/d2xxjava/MyApplication;.testStatic(I, Landroid/content/Context)V"
    W/System.err(15479): at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method)
    W/System.err(15479): at org.qtproject.qt5.android.QtNative$6.run(QtNative.java:365)
    W/System.err(15479): at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
    W/System.err(15479): at java.lang.Thread.run(Thread.java:818)

    Here is my Java code :
    0_1556619776942_fc08a8c5-0cd9-4dda-a3ab-a42753c6e9c3-image.png

    C++ call :
    0_1556619910740_c03d51f0-fcc5-46d4-8cbc-34ee3b3930c3-image.png

    "MyApplication" Class doesn't extend QtActivity, can it be the problem?
    If I do so, I get an other error :

    F/art (17395): sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception 'java.lang.RuntimeException' thrown in unknown throw location
    F/art (17395): sart/runtime/check_jni.cc:65] in call to GetMethodID
    F/art (17395): sart/runtime/check_jni.cc:65] from void org.qtproject.qt5.android.QtNative.startQtApplication()
    F/art (17395): sart/runtime/check_jni.cc:65] "qtMainLoopThread" prio=5 tid=5 Runnable
    F/art (17395): sart/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x12c231c0 self=0xab350fb8
    F/art (17395): sart/runtime/check_jni.cc:65] | sysTid=17471 nice=0 cgrp=default sched=0/0 handle=0xab2dafd0
    F/art (17395): sart/runtime/check_jni.cc:65] | state=R schedstat=( 230849873 94922049 241 ) utm=23 stm=0 core=1 HZ=100
    F/art (17395): sart/runtime/check_jni.cc:65] | stack=0x4c11e000-0x4c120000 stackSize=1036KB
    F/art (17395): sart/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held)
    F/art (17395): sart/runtime/check_jni.cc:65] native: #00 pc 00004e84 /system/lib/libbacktrace_libc++.so (_ZN13UnwindCurrent6UnwindEjP8ucontext+23)
    F/art (17395): sart/runtime/check_jni.cc:65] native: #01 pc 0000369d /system/lib/libbacktrace_libc++.so (_ZN9Backtrace6UnwindEjP8ucontext+8)

    Thanks

    raven-worxR 1 Reply Last reply
    0
    • D Damalo_02

      Hello,

      I would like to do an Android app using FTDI Java library and Qt.
      Firstly, because I found easier to code in Java, I did my app on Android Studio and it works well.
      FTDI methods use application context as argument : 0_1556619455603_d6c28dfc-5c7b-4f83-a142-b7358398789d-image.png

      Now I'm trying to do the same app on Qt Creator.
      As a simple example, I'm just trying to call a Java method (that uses application context) from C++ using JNI.

      The problem is I'm getting this error and I don't know how to solve it :

      W/System.err(15479): java.lang.NoSuchMethodError: no static method "Lcom/ftdi/d2xxjava/MyApplication;.testStatic(I, Landroid/content/Context)V"
      W/System.err(15479): at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method)
      W/System.err(15479): at org.qtproject.qt5.android.QtNative$6.run(QtNative.java:365)
      W/System.err(15479): at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
      W/System.err(15479): at java.lang.Thread.run(Thread.java:818)

      Here is my Java code :
      0_1556619776942_fc08a8c5-0cd9-4dda-a3ab-a42753c6e9c3-image.png

      C++ call :
      0_1556619910740_c03d51f0-fcc5-46d4-8cbc-34ee3b3930c3-image.png

      "MyApplication" Class doesn't extend QtActivity, can it be the problem?
      If I do so, I get an other error :

      F/art (17395): sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception 'java.lang.RuntimeException' thrown in unknown throw location
      F/art (17395): sart/runtime/check_jni.cc:65] in call to GetMethodID
      F/art (17395): sart/runtime/check_jni.cc:65] from void org.qtproject.qt5.android.QtNative.startQtApplication()
      F/art (17395): sart/runtime/check_jni.cc:65] "qtMainLoopThread" prio=5 tid=5 Runnable
      F/art (17395): sart/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x12c231c0 self=0xab350fb8
      F/art (17395): sart/runtime/check_jni.cc:65] | sysTid=17471 nice=0 cgrp=default sched=0/0 handle=0xab2dafd0
      F/art (17395): sart/runtime/check_jni.cc:65] | state=R schedstat=( 230849873 94922049 241 ) utm=23 stm=0 core=1 HZ=100
      F/art (17395): sart/runtime/check_jni.cc:65] | stack=0x4c11e000-0x4c120000 stackSize=1036KB
      F/art (17395): sart/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held)
      F/art (17395): sart/runtime/check_jni.cc:65] native: #00 pc 00004e84 /system/lib/libbacktrace_libc++.so (_ZN13UnwindCurrent6UnwindEjP8ucontext+23)
      F/art (17395): sart/runtime/check_jni.cc:65] native: #01 pc 0000369d /system/lib/libbacktrace_libc++.so (_ZN9Backtrace6UnwindEjP8ucontext+8)

      Thanks

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Damalo_02 said in Problem using context and JNI:

      (I, Landroid/content/Context)V

      is not a correct JNI signature.
      Correct: (ILandroid/content/Context)V

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      KroMignonK 1 Reply Last reply
      3
      • raven-worxR raven-worx

        @Damalo_02 said in Problem using context and JNI:

        (I, Landroid/content/Context)V

        is not a correct JNI signature.
        Correct: (ILandroid/content/Context)V

        KroMignonK Offline
        KroMignonK Offline
        KroMignon
        wrote on last edited by KroMignon
        #3

        @raven-worx said in Problem using context and JNI:

        Correct: (ILandroid/content/Context)V

        I think you missed a semicolone symbole and it should be (ILandroid/content/Context;)V

        => cf. JNI Types and Data Structures

        Regards

        Fabrice

        It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

        1 Reply Last reply
        2
        • D Offline
          D Offline
          Damalo_02
          wrote on last edited by
          #4

          Yes it was a problem of JNI signature, and you're right @KroMignon a semicolon is missing.

          Right signature is : (ILandroid/content/Context;)V

          Thanks a lot for your help

          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