005 android jni 一个简单的报错

在android中使用ndk开发需要使用到jni。

1. java.lang.UnsatisfiedLinkError: No implementation found for void com.frank.smart.smarthome.JniSocket.test() (tried Java_com_frank_smart_smarthome_JniSocket_test and Java_com_frank_smart_smarthome_JniSocket_test__)

原因:
public class JniSocket {
static {
System.loadLibrary("SmartSocket");
}

    public native void test();
}

其中指令没有被执行,改为如下运行正常;
public class JniSocket {

    JniSocket()
    {
        //static {
            System.loadLibrary("SmartSocket");

    }
    public native void test();
}

检查jni类似错误的方法

  1. 确保System.loadLibrary()函数一定被执行了加载了库。
  2. 对应函数函数名是否正确;
  3. 对应参数是否正确;
posted @ 2015-10-28 11:42  夏大王  阅读(454)  评论(0编辑  收藏  举报