在android中使用ndk開發(fā)需要使用到j(luò)ni。
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();
}
其中指令沒有被執(zhí)行,改為如下運行正常;
public class JniSocket {
JniSocket()
{
//static {
System.loadLibrary("SmartSocket");
}
public native void test();
}
檢查jni類似錯誤的方法
- 確保System.loadLibrary()函數(shù)一定被執(zhí)行了加載了庫。
- 對應(yīng)函數(shù)函數(shù)名是否正確;
- 對應(yīng)參數(shù)是否正確;