问题
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
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/6096355/no-implementation-found-for-native