Sdkbox iap jni error

Hello!
I’m integrating SDKBOX IAP into a cocos 3.14 project. iOS works just fine, Android compiles and runs, but I get a crash when I try to purchase the item with this error message:

JNI DETECTED ERROR IN APPLICATION: jstring is an invalid local reference: 0x1 (0xdead4321)
in call to GetStringUTFChars
from void com.sdkbox.plugin.IAPWrapper.nativeOnPayResult(java.lang.String, int, java.lang.String)

Please advice!!

Best,

Davide

Can you let us know which version of SDKBOX IAP are you using?

Hei,

Can IAP work now ?
We also provide [cpp, Lua, JS sample] (https://github.com/sdkbox/sdkbox-sample-iap).

Hello guys!
I was able to fix it downloading the cpp sample and importing the .jars from there! Thanks!!

I have this error iap 2.4.0.2, cocos2d-x 3.12, c++, Android

: Fatal signal 6 (SIGABRT), code 0 in tid 3666 (GLThread 5664)
: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
: Build fingerprint: 'samsung/a5ltexx/a5lte:6.0.1/MMB29M/A500FXXS1CQC1:user/release-keys'
: Revision: '10'
: ABI: 'arm'
: pid: 3651, tid: 3666, name: GLThread 5664  >>> com.quizgeek <<<
: signal 6 (SIGABRT), code 0 (SI_USER), fault addr --------
: Abort message: 'art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: use of invalid     jobject 0x1315a520'
:     r0 00000000  r1 00000e52  r2 00000006  r3 a0570978
:     r4 a0570980  r5 a0570930  r6 00000001  r7 0000010c
:     r8 b77062c0  r9 b41c1378  sl 00000000  fp 00000000
:     ip 00000006  sp a0570060  lr b6cfaf15  pc b6cfd310  cpsr 40070010
:
: backtrace:
:     #00 pc 00044310  /system/lib/libc.so (tgkill+12)
:     #01 pc 00041f11  /system/lib/libc.so (pthread_kill+32)
:     #02 pc 0001ba13  /system/lib/libc.so (raise+10)
:     #03 pc 00018c81  /system/lib/libc.so (__libc_android_abort+34)
:     #04 pc 00016840  /system/lib/libc.so (abort+4)
:     #05 pc 00321c71  /system/lib/libart.so (_ZN3art7Runtime5AbortEv+212)
:     #06 pc 000f3dfd  /system/lib/libart.so (_ZN3art10LogMessageD2Ev+2212)
:     #07 pc 00250335  /system/lib/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1524)
:     #08 pc 00250741  /system/lib/libart.so (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+68)
:     #09 pc 0033ea93  /system/lib/libart.so (_ZNK3art6Thread13DecodeJObjectEP8_jobject+174)
:     #10 pc 0026ec43  /system/lib/libart.so (_ZN3art3JNI17GetStringUTFCharsEP7_JNIEnvP8_jstringPh+318)
:     #11 pc 00362f59  /mnt/asec/com.quizgeek-2/lib/arm/libMyGame.so (_ZN6sdkbox8JNIUtils20NewStringFromJStringEP8_jstringP7_JNIEnv+64)
:     #12 pc 003547f9  /mnt/asec/com.quizgeek-2/lib/arm/libMyGame.so (Java_com_sdkbox_plugin_IAPWrapper_nativeOnPayResult2+92)
:     #13 pc 00b7612d  /data/dalvik-cache/arm/mnt@asec@com.quizgeek-2@base.apk@classes.dex (offset 0x8bd000)

I buy product, get message “payment successful” and than crash.

I got you. And maybe https://stackoverflow.com/a/46313192/5443510 is the key.

Hi @Pearson, I have a small fix with this issue. But I need your help to test it.

https://www.dropbox.com/s/6lrb022i7yfw3n0/sdkbox-iap_v2.4.0.3.zip?dl=0

Thanks,

Hi @yinjimmy! I have the same problem.

: Fatal signal 6 (SIGABRT), code 0 in tid 3430 (GLThread 9773)
: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
: Build fingerprint: 'samsung/a5ltexx/a5lte:6.0.1/MMB29M/A500FXXS1CQC1:user/release-keys'
: Revision: '10'
: ABI: 'arm'
: pid: 3410, tid: 3430, name: GLThread 9773  >>> com.quizgeek <<<
: signal 6 (SIGABRT), code 0 (SI_USER), fault addr --------
: Abort message: 'art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: use of invalid jobject 0x131eef20'
:     r0 00000000  r1 00000d66  r2 00000006  r3 a04fe978
:     r4 a04fe980  r5 a04fe930  r6 00000001  r7 0000010c
:     r8 b83752c0  r9 b4216378  sl 00000000  fp 00000000
:     ip 00000006  sp a04fe070  lr b6d4ff15  pc b6d52310  cpsr 40070010
:
: backtrace:
:     #00 pc 00044310  /system/lib/libc.so (tgkill+12)
:     #01 pc 00041f11  /system/lib/libc.so (pthread_kill+32)
:     #02 pc 0001ba13  /system/lib/libc.so (raise+10)
:     #03 pc 00018c81  /system/lib/libc.so (__libc_android_abort+34)
:     #04 pc 00016840  /system/lib/libc.so (abort+4)
:     #05 pc 00321c71  /system/lib/libart.so (_ZN3art7Runtime5AbortEv+212)
:     #06 pc 000f3dfd  /system/lib/libart.so (_ZN3art10LogMessageD2Ev+2212)
:     #07 pc 00250335  /system/lib/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1524)
:     #08 pc 00250741  /system/lib/libart.so (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+68)
:     #09 pc 0033ea93  /system/lib/libart.so (_ZNK3art6Thread13DecodeJObjectEP8_jobject+174)
:     #10 pc 0026ec43  /system/lib/libart.so (_ZN3art3JNI17GetStringUTFCharsEP7_JNIEnvP8_jstringPh+318)
:     #11 pc 00369d39  /mnt/asec/com.quizgeek-1/lib/arm/libMyGame.so (_ZN6sdkbox8JNIUtils20NewStringFromJStringEP8_jstringP7_JNIEnv+44)
:     #12 pc 0035c8f9  /mnt/asec/com.quizgeek-1/lib/arm/libMyGame.so (Java_com_sdkbox_plugin_IAPWrapper_nativeOnPayResult2+72)
:     #13 pc 00b7612d  /data/dalvik-cache/arm/mnt@asec@com.quizgeek-1@base.apk@classes.dex (offset 0x8bd000)

Got you, let me make more researching.
And one more thing, we use NDK r14b to generate all plugins, which NDK you use?

I use ndk-r12b.

I have tried ndk-r16b and have the same problem.

another one https://www.dropbox.com/s/51h2ladc1rbsetj/sdkbox-iap_v2.4.0.3-2.zip?dl=0

plz help to test,
Thanks again.

I can’t init my product list. (NDK r12b, r16b) In the previous version initialization works

E SDKBOX_CORE: Checking plugin status for unknown plugin: iap
D IAP     : creating Products list:
I SDKBOX_CORE: Initialization request for plugin: 'com/sdkbox/plugin/SDKBoxIABBillingClient'
E SDKBOX_CORE: Plugin com/sdkbox/plugin/SDKBoxIABBillingClient not found.
W System.err: java.lang.ClassNotFoundException: com.sdkbox.plugin.SDKBoxIABBillingClient
W System.err: 	at java.lang.Class.classForName(Native Method)
W System.err: 	at java.lang.Class.forName(Class.java:324)
W System.err: 	at java.lang.Class.forName(Class.java:285)
W System.err: 	at com.sdkbox.plugin.SDKBox.initPlugin(SDKBox.java:186)
W System.err: 	at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native Method)
W System.err: 	at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:105)
W System.err: 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1647)
W System.err: 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1352)
W System.err: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sdkbox.plugin.SDKBoxIABBillingClient" on path: DexPathList[[zip file "/mnt/asec/com.quizgeek-2/base.apk"],nativeLibraryDirectories=[/mnt/asec/com.quizgeek-2/lib/arm, /mnt/asec/com.quizgeek-2/base.apk!/lib/armeabi, /vendor/lib, /system/lib]]
W System.err: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
W System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
W System.err: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
W System.err: 	... 8 more
W System.err: 	Suppressed: java.lang.ClassNotFoundException: com.sdkbox.plugin.SDKBoxIABBillingClient
W System.err: 		at java.lang.Class.classForName(Native Method)
W System.err: 		at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
W System.err: 		at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
W System.err: 		at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
W System.err: 		... 9 more
W System.err: 	Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
I IAP     : AndroidManifest has no store metadata. Defaulting to 'googleplay
E IAP     : Can't create IAP java object of type: ''.
E SDKBOX_CORE: JNIInvoke with null obj ref.
E SDKBOX_CORE: JNIInvoke with null obj ref.
E SDKBOX_CORE: JNIInvoke with null obj ref.
E SDKBOX_CORE: JNIInvoke with null obj ref.

plz copy all jars and remove PluginGooglePlay.jar.
Thanks,

I can’t use support-annotations-27.1.1.jar because it conflicted with android-support-v4.jar in facebook_lib.
com.android.dex.DexException: Multiple dex files define Landroid/support/annotation/AnimRes;

without support-annotations-27.1.1.jar and PluginGooglePlay.jar I have that problem on initialization.

E SDKBOX_CORE: Checking plugin status for unknown plugin: iap
D IAP     : creating Products list:
I SDKBOX_CORE: Initialization request for plugin: 'com/sdkbox/plugin/SDKBoxIABBillingClient'
I IAP     : AndroidManifest has no store metadata. Defaulting to 'googleplay
D SDKBoxIABBillingClient: BillingClient: Start connection...
D SDKBoxIABBillingClient: handlePurchaseResult:-1
W BillingClient: getPurchaseHistory is not supported on current device
D SDKBoxIABBillingClient: handlePurchaseResult:-2
D SDKBoxIABBillingClient: onBillingSetupFinished:0

i import facebook to sdkbox-sample-iap cpp, and can compile success.

and i unzip android_support_v7\appcompat\libs\android-support-v4.jar, it didn’t include android/support/annotation,

i didn’t find android-support-v4.jar in facebook_lib

can you use staging to test,
sdkbox import iap --staging
sdkbox import facebook --staging

@Pearson plz wait, i have not checkin the jni fixing code. so it 's not included in staging.

The jni fixing code has been checkin.

sdkbox import iap --staging --forcedownload --forcecopy
# or
sdkbox update --staging --forcedownload --forcecopy

hi all , still some SDKBox JNI crash ?

I returned to the old versions because I could not compile IAP, GA, and Facebook together (Multiple dex files define ). Now I use cocos 3.17 sdkbox 2.4.3.3 and it works.