I'm trying to debug my JNI function, and in doing so I wish to display the incoming jstring argument to logcat to verify its correctness.
I've tried the following code to do so, but it keeps crashing out.
LOGD(myStringArg);
where myStringArg is declared as a jstring.
If I declare and define another jstring within my JNI function and LOGD that, it works. However, for some reason if I call LOGD on the JNI function argument it crashes. I have verified internally that the jstring is not null, and right before calling it in the Java function, I also check that the value is correct.
I've converted the jstring to a const char * as follows:
const char *charString;
charString = (const char*)(*env)->GetStringUTFChars(env, myStringArg, NULL);
LOGD(charString);
Nothing is displayed, which means charString is empty?
Any idea how to do this?
Thanks.
 
     
     
     
    