没有找到实现本机 [英] No implementation found for native

查看:108
本文介绍了没有找到实现本机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编译我的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.

这篇关于没有找到实现本机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆