Android NDK - Unable to use jstring, keeps crashing

I've spent the last two days on a JNI issue and it was driving me crazy ... I'm just trying to do:

  SWIGEXPORT void JNICALL Java_com_my_package_CM_1CoreJNI_CM_1Property_1name_1set(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
    const char *arg2 = (*jenv)->GetStringUTFChars(jenv, jarg2, 0);
    ....
}

      

I call this function via JAR and it keeps crashing. All I can read from my LogCat:

03-27 12:44:29.162: E/dalvikvm(1599): JNI ERROR (app bug): accessed stale weak global reference 0x4080f657 (index 15765 in a table of size 0)
03-27 12:44:29.172: W/dalvikvm(1599): JNI WARNING: jstring is an invalid weak global reference (0x4080f657)
03-27 12:44:29.172: W/dalvikvm(1599):              in Lcom/my/package/CM_CoreJNI;.CM_Property_name_set:(JLjava/lang/String;)V (GetStringUTFChars)

      

After a lot of research, I tried to call this function directly from my activity (adding my own set of voids ...) and it worked fine! I'm blocked and don't know how to do it ...

Did anyone manage to call JNI from the JAR?

EDIT: Fixed by removing the jar and adding .java files ...

+3
android jni


source to share


No one has answered this question yet

Check out similar questions:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to persist android activity state by persisting instance state?
2097
Is there a way to run Python on Android?
1858
"Debug certificate expired" error in Android Eclipse plugins
1844
What is "Context" on Android?
1296
Reloading activity on android rotation
1
jni undefined symbol error



All Articles
Loading...
X
Show
Funny
Dev
Pics