没有找到实现本机本机、没有找到

由网友(枕上书)分享简介:我编译我的C源与Android的NDK然后我把.so文件在我的Andr​​oid项目的libs文件夹,但是当我调用本机的功能,我有一个没有找到实现原生的错误。如果我尝试打电话给亚行的shell一切该功能正常工作,所以我不明白为什么这个错误。请帮忙,安德烈I compiled my c sources with...

我编译我的C源与Android的NDK然后我把.so文件在我的Andr​​oid项目的libs文件夹,但是当我调用本机的功能,我有一个没有找到实现原生的错误。 如果我尝试打电话给亚行的shell一切该功能正常工作,所以我不明白为什么这个错误。 请帮忙, 安德烈

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

推荐答案

有涉及JNI一个确切的命名方案,该方案不是很明显。也许你的功能实现不符合呢?

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

例如,如果你希望能够调用名为startserver的从你的JAVA code本机的功能,假设你的包被称为com.example.something和你的类叫做MyClass的,你应该有一个成员函数在你的Java类,如下所示:

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();

和那么你的JNI的实现应该是这样的:

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.

阅读全文

相关推荐

最新文章