我正在制作一个使用了一些本机方法的应用程序,这些方法在一个单独的类中定义。当我在我的 Activity 类中创建该类的实例时,就会发生这种类型的错误。
这是我的活动课
public class LoginActivity extends Activity
{
PortSipSdk sdk;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.loginview);
sdk = PortSipSdk.getInstance();//error is occurs at this line
sdk.setOnRegisterListener(this);
}
}
Java 类是
public class PortSipSdk {
private final String TAG = "PortSipSdk";
private static PortSipSdk instance;
private PortSipNetwork mNetAssist;
private KeyguardLock mKeyguardLock;
private Context mContext;
long mSessionID = PortSipErrorcode.INVALID_SESSION_ID;
public synchronized static PortSipSdk getInstance() {
if (instance == null) {
instance = new PortSipSdk();
}
return instance;
}
private PortSipSdk() {
msgDispatcher = new MainHandler();
setMessageHandler(msgDispatcher);
videoRecorder = new PortSipVideoRecoder();
}
public native void setMessageHandler(Handler msghandler);
// Initialize and register functions
private native int initializeSDK(int enum_transport, String agent,
String STUNServer, int STUNServerPort);
}
日志是
07-30 12:13:01.852: E/AndroidRuntime(651): FATAL EXCEPTION: main
07-30 12:13:01.852: E/AndroidRuntime(651): java.lang.UnsatisfiedLinkError: setMessageHandler
07-30 12:13:01.852: E/AndroidRuntime(651): at com.portsip.PortSipSdk.setMessageHandler(Native Method)
07-30 12:13:01.852: E/AndroidRuntime(651): at com.portsip.PortSipSdk.<init>(PortSipSdk.java:62)
07-30 12:13:01.852: E/AndroidRuntime(651): at com.portsip.PortSipSdk.getInstance(PortSipSdk.java:55)
07-30 12:13:01.852: E/AndroidRuntime(651): at com.portsip.test.LoginActivity.onCreate(LoginActivity.java:48)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.os.Looper.loop(Looper.java:123)
07-30 12:13:01.852: E/AndroidRuntime(651): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-30 12:13:01.852: E/AndroidRuntime(651): at java.lang.reflect.Method.invokeNative(Native Method)
07-30 12:13:01.852: E/AndroidRuntime(651): at java.lang.reflect.Method.invoke(Method.java:521)
07-30 12:13:01.852: E/AndroidRuntime(651): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-30 12:13:01.852: E/AndroidRuntime(651): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-30 12:13:01.852: E/AndroidRuntime(651): at dalvik.system.NativeStart.main(Native Method)