0

我正在尝试将 PJSIP 添加到 android 项目并进行测试运行。
我遵循了PSIP 的官方文档

运行项目时出现以下错误

E/art: No implementation found for void org.pjsip.pjsua2.pjsua2JNI.swig_module_init() (tried Java_org_pjsip_pjsua2_pjsua2JNI_swig_1module_1init and Java_org_pjsip_pjsua2_pjsua2JNI_swig_1module_1init__)
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
                  Process: com.tizinmobile.test_pjsip, PID: 3323
                  java.lang.UnsatisfiedLinkError: No implementation found for void org.pjsip.pjsua2.pjsua2JNI.swig_module_init() (tried Java_org_pjsip_pjsua2_pjsua2JNI_swig_1module_1init and Java_org_pjsip_pjsua2_pjsua2JNI_swig_1module_1init__)
                      at org.pjsip.pjsua2.pjsua2JNI.swig_module_init(Native Method)
                      at org.pjsip.pjsua2.pjsua2JNI.<clinit>(pjsua2JNI.java:2628)
                      at org.pjsip.pjsua2.pjsua2JNI.new_Endpoint(Native Method)
                      at org.pjsip.pjsua2.Endpoint.<init>(Endpoint.java:0)
                      at com.tizinmobile.test_pjsip.MainActivity.onCreate(MainActivity.java:14)
                      at android.app.Activity.performCreate(Activity.java:6876)
                      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
                      at android.app.ActivityThread.access$1100(ActivityThread.java:221)
                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
                      at android.os.Handler.dispatchMessage(Handler.java:102)
                      at android.os.Looper.loop(Looper.java:158)
                      at android.app.ActivityThread.main(ActivityThread.java:7224)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

我尝试了什么:

  1. 为多个 ABI 目标构建 PJSIP
  2. Ran swig 用 .so 文件创建 android 示例项目
  3. 将这些文件复制到 app/lib
  4. Gradle 中的设置以包含 .so 文件

摇篮设置:

android {
    sourceSets {
        main {
            jniLibs.srcDirs = ['libs']
        }
    }        
}

项目结构

── libs
│   ├── arm64-v8a
│   ├── armeabi
│   ├── armeabi-v7a
│   ├── mips64
│   ├── x86
│   └── x86_64
└── src
    ├── androidTest
    │   └── java
    ├── main
    │   ├── java
    │   └── res
    └── test
        └── java
4

1 回答 1

-1

在我的代码中添加这个修复了错误:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        System.loadLibrary("pjsua2");
        System.out.println("Library loaded");
    }
于 2018-10-22T09:42:55.297 回答