I am writing the following code in the HelloWorld.c file:

 #include <jni.h> JNIEXPORT jstring JNICALL Java_ru_anya_helloworldndk_HelloWorld_messageFromNativeCode (JNIEnv * env, jobject jObj) { return (*env)->NewStringUTF(env, "Hello World from c!"); } 

With the help of ndk-build directly from the console, everything is collected correctly. From Eclipse with the NDK plugin on NewStringUTF shows the error Method could not be resolved. Accordingly, the program does not start.

And what is most interesting! If you delete this error from the Problems tab, the program starts successfully, the required method is executed, there are no errors. That is, the required method is there, everything is built normally, but it shows an error. In this case, opposite the error in the code is the beetle icon.

Now I have completely turned off the error Method could not be resolved, everything works, but then if there is really no method, this situation will not catch.

How to solve this problem in a different way and what is the matter here?

  • Most likely, Eclipse does not see the jni.h header. Try to move (put the cursor) on the drain with the switch and press F3 (to go to this file). If it fails, then it will be necessary to set the path to this header in the Eclipse settings. - KryDos
  • I tried it, the file shows it, it takes it from ndk. - anutakay