运行PJSUA时出错

时间:2018-02-16 11:31:01

标签: android pjsip pjsua2

我正在尝试将PJSIP添加到Android项目中并进行测试运行 我跟着official documentation of 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. 使用.so文件
  3. 启动swig以创建android示例项目
  4. 将这些文件复制到app / lib
  5. Gradle中的设置以包含.so文件
  6. Gradle设置:

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

    项目结构

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

1 个答案:

答案 0 :(得分:-1)

在我的代码中添加此命令可修复错误:

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

        System.loadLibrary("pjsua2");
        System.out.println("Library loaded");
    }