I am working on a simple OpenCV code to display an image after undergoing sobel operation. I have included all the necessary paths to the Project Properties for including the OpenCV4Android
folder. I resolved all the errors except one:
Error: Method NewStringUTF() could not be resolved
I included <jni.h>
I have also included AndroidNDK folder in the project paths. My Eclipse is highly unpredictable. Earlier, it worked fine when i developed other application on Android. Is eclipse machine dependent? What can i do to fix this error?
Chances are that you are using C
syntax in CPP
file
I had the same error
Just switch to the right syntax and Problem will be solved C syntax
return (*env)->NewStringUTF(env, "Hello from JNI !");
C++ Syntax
return (env)->NewStringUTF("Hello from JNI !");
After switching from C to C++ syntax my problem got solved.
I had this issue. Based on my "solution," it seems to be something funny going on in Eclipse, since I had another project open with (as far as I was able to tell) the exact some properties, paths, etc., besides for being labeled a Library Project.
Just by observing the corresponding struct in jhi.h, the callback prototypes are all there! Ctrl-click the include statement and Eclipse will even link you the reference!
Go to the project's Properties -> C/C++ General -> Code Analysis. Click the "Use project settings" radio button (or "Configure Workspace Settings..." button). Disable (uncheck) the "Method cannot be resolved" checkbox. Click "Apply," "OK." Then for your project, refresh, clean, refresh, build.
There must have been something I did differently in creating the new project. Or maybe it was because of the locations of the projects, or the fact that the previous was a Library. Maybe it really is an Eclipse bug? For reference, I'm using ADT v21.1.0-569685 and NDK r8e for Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With