title: JNI on Android: How to retrieve a string from Java code?
body: <p>I read a lot of examples to retrieve a java string in C/C++ code, but it seems that I miss something. this simple code doesn't work..</p>
  
  <p>In ActivityTest  (android java code) I've:</p>
  
  <pre><code>public static native void nativeInit(String stringfromjava);
  </code></pre>
  
  <p>In TestActivity I've:</p>
  
  <pre><code>ActivityTest.nativeInit("test");
  </code></pre>
  
  <p>and in my test-jni.c:</p>
  
  <pre><code>JNIEXPORT void JNICALL  Java_com_test_jni_ActivityTest_nativeInit(JNIEnv* env, jclass cls, jobject obj, jstring stringfromjava){
  
  __android_log_print(ANDROID_LOG_INFO, "TESTJNI","Native Init started");
  
  const char* w_buf = (*env)-&gt;GetStringUTFChars(env, stringfromjava, 0);
  
  if(w_buf == NULL) {
      __android_log_print(ANDROID_LOG_INFO, "TESTJNI","file path recv nothing");
  }
  
  else {
          __android_log_print(ANDROID_LOG_INFO, "TESTJNI","String: %s", w_buf);
  }
  
  (*env)-&gt;ReleaseStringUTFChars(env, stringfromjava, w_buf);
  
  }
  </code></pre>
  
  <p>But in my logcat I get only:</p>
  
  <pre><code>I/TESTJNI (18921): Native Init started
  I/TESTJNI (18921): String: 
  </code></pre>
  
  <p>Where I'm wrong...?</p>
  
  <p><strong>FIXED</strong>
  Thanks to Mario, removing "jobject obj" from the signature fixed my issue!</p>