Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No implementation found for native [closed]

I compiled my c sources with android-ndk then I put the .so file in the libs folder of my android project but when I call the native function i have a "No implementation found for native" error. If I try to call this function from adb shell everything works fine so I don't understand why that error. Please help, Andrea

like image 314
Andrea Giancarli Avatar asked May 23 '11 11:05

Andrea Giancarli


2 Answers

There is an exact naming scheme involved with JNI which is not very obvious. Perhaps your function implementation is not conforming to it?

For example, if you want to be able to call a native function called startServer from your JAVA code, assuming your package is called com.example.something and your class is called MyClass, you should have a member function in your JAVA class like so:

private native void startServer();

And then your JNI implementation should look like this:

JNIEXPORT void Java_com_example_something_MyClass_startServer(JNIEnv *env, jobject obj) {  

// Do something here...

}

Otherwise, there is a linkage error.

like image 61
gby Avatar answered Oct 16 '22 23:10

gby


Another reason you can get this, is if your not calling your library at the time you are making a JNI function call:

static {
    System.loadLibrary("myJNIFILE");
}

should be called somewhere before the actual reference to a JNI function.

like image 42
j2emanue Avatar answered Oct 16 '22 23:10

j2emanue