gpt4 book ai didi

android - 不满意链接错误 : setMessageHandler(Native Method)

转载 作者:太空狗 更新时间:2023-10-29 15:09:43 25 4
gpt4 key购买 nike

我正在制作一个应用程序,其中我使用了一些 native 方法,这些方法在单独的类中定义。当我在 Activity 类中创建该类的实例时,就会发生这种类型的错误。

这是我的 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)

最佳答案

确保您的 NDK 二进制文件在您的 APK 中。

关于android - 不满意链接错误 : setMessageHandler(Native Method),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17940541/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com