Home > Mobile >  On c + + and Java in QtForAndroid intermodulation problem
On c + + and Java in QtForAndroid intermodulation problem

Time:09-20

In c + + before calling Java, just need to find out the type of Java and c + + corresponding relation, and callStaticMethod function calls, but c + +, Java call me in the book "Qt On Android core programming" see the authors say is very simple, is generally only need to define a Java function as the native, then c + + defines a corresponding function of two parameters, link again can, but probably Qt version relations (the author USES the version 5.3, now I use the 5.11 and 5.14), with examples of the author, or write their own always flash back, current situation is as follows:
1, Qt thread, and the Android main thread is not the same thread, so two threads should be used under what circumstances?
2, registerNativeMethods () function defined correctly and properly returned, but after the call will lead to part of the c + + Java function called flash back (if not call registerNativeMethods (), is no problem),
3, Java calls Qt function (sample), after the call will flash back, function stack interception of the following (this is the error of 5.14 and 5.11 is not quite same, is a null object) :

E art: JNI ERROR (app bug) : accessed does global reference zero x2008aa
F art: art/runtime/java_vm_ext. Cc: 470] the JNI DETECTED the ERROR IN the APPLICATION: the use of does global reference zero x2008aa
F art: art/runtime/java_vm_ext. Cc: 470] the from Java. Lang. String an. Qt. ExtendsQtWithJava. ExtendsQtNative. GetQtVersion ()
F art: art/runtime/java_vm_ext. Cc: 470] "main" prio=5 tid=1 Runnable
F art: art/runtime/java_vm_ext. Cc: 470] | group="main" sCount=0 dsCount=0 obj=0 x759b96b8 self=0 xf0a05400
F art: art/runtime/java_vm_ext. Cc: 470] | sysTid=nice=27734-10 CGRP=default sched handle=0/0=0 xf381c534
F art: art/runtime/java_vm_ext. Cc: 470] | state=R schedstat=(385390111, 19337303, 757) utm=21 STM=17 core=4 HZ=100
F art: art/runtime/java_vm_ext. Cc: 470] | stack xff4b4000=0-0 xff4b6000 stackSize=8 MB
F art: art/runtime/java_vm_ext. Cc: 470] | by mutexes="mutator lock" (Shared by)
F art: art/runtime/java_vm_ext. Cc: 470] native: # 00 PC 003577 e5/system/lib/libart. So (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv + 128)
F art: art/runtime/java_vm_ext. Cc: 470] native: # 01 00337 dc1 PC/system/lib/libart. So (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap + 304)
F art: art/runtime/java_vm_ext. Cc: 470] native: # 02 PC 0023 ba63/system/lib/libart. So (_ZN3art9JavaVMExt8JniAbortEPKcS2_ + 846)
F art: art/runtime/java_vm_ext. Cc: 470] native: # 3 PCS 0023 c00f/system/lib/libart. So (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z + 66)
F art: art/runtime/java_vm_ext. Cc: 470] native: # 4 PCS 0033 b81d/system/lib/libart. So (_ZNK3art6Thread13DecodeJObjectEP8_jobject + 240)
F art: art/runtime/java_vm_ext. Cc: 470] native: # 5 PCS 003 fbf8f/system/lib/libart. So (_ZN3art25JniMethodEndWithReferenceEP8_jobjectjPNS_6ThreadE + 30)
F art: art/runtime/java_vm_ext. Cc: 470] native: # 6 PC 00000067/data/app/an qt. ExtendsQtWithJava - 1/oat/arm/base. Odex Java_an_qt_extendsQtWithJava_ExtendsQtNative_GetQtVersion__ (+ 82)
F art: art/runtime/java_vm_ext. Cc: 470] at the an. Qt. ExtendsQtWithJava. ExtendsQtNative. GetQtVersion (Native method)
F art: art/runtime/java_vm_ext. Cc: 470] at the an. Qt. ExtendsQtWithJava. ExtendsQtWithJava $1. HandleMessage (43) extendsQtWithJava. Java:
F art: art/runtime/java_vm_ext. Cc:. 470] at the android OS. Handler. DispatchMessage (Handler. Java: 105)
F art: art/runtime/java_vm_ext. Cc:. 470] at the android OS. Stars. Loop (156). Which Java:
F art: art/runtime/java_vm_ext. Cc:. 470] at the android app. ActivityThread. Main (6517) ActivityThread. Java:
F art: art/runtime/java_vm_ext. Cc: 470] the at Java lang. Reflect. Method. Invoke! (Native method)
F art: art/runtime/java_vm_ext. Cc: 470] the at com. Android. Internal. OS. $MethodAndArgsCaller ZygoteInit. Run (ZygoteInit. Java: 942)
F art: art/runtime/java_vm_ext. Cc: 470] at the android. Internal. OS. ZygoteInit. Main (ZygoteInit. Java: 832)
F art: art/runtime/java_vm_ext. Cc: 470] the at DE. Robv. Android. Xposed. XposedBridge. Main (107) XposedBridge. Java:


Please communicate, carries forward the Qt technology together!

CodePudding user response:

To solve the ~ ~ ~
  •  Tags:  
  • Qt
  • Related