我在我的android项目中使用PJSIP,它运行良好。现在,我需要在我的项目中添加Opus-Android lib。代码编译得很好,但是在启动应用程序时会出现问题。它给了我以下例外:
ava.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.matsoltech.android.chatellite-1/base.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.matsoltech.android.chatellite-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.matsoltech.android.chatellite-1/lib/arm64, /data/app/com.matsoltech.android.chatellite-1/base.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/com.matsoltech.android.chatellite-1/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]] couldn't find "libpjsua2.so"
at java.lang.Runtime.loadLibrary0(Runtime.java:984)
at java.lang.System.loadLibrary(System.java:1530)
at com.matsoltech.android.chatellite.utils.pjsua_utils.MyApp.<clinit>(MyApp.java:51)
at com.matsoltech.android.chatellite.utils.service.MainService.setupPJSUA(MainService.java:99)
at com.matsoltech.android.chatellite.utils.service.MainService.onStartCommand(MainService.java:90)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3326)
at android.app.ActivityThread.-wrap21(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1582)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
一旦我从gradle中删除Opus,pjsip lib就会开始正常工作。
以下是我的依赖项:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'ch.acra:acra:4.9.0'
compile 'org.java-websocket:Java-WebSocket:1.3.0'
compile 'top.oply.opuslib:opuslib:1.0.2'
testCompile 'junit:junit:4.12'
}
我的应用程序的gradle:
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.matsoltech.android.chatellite"
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName code.toString()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "libpjsua2"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
jniDebuggable true
}
}
抛出的异常就在这里:
static {
System.loadLibrary("pjsua2");
System.out.println("Library loaded");
}
那么,我在哪里做错了?
答案 0 :(得分:0)
你需要这个,那么你的代码应该可以工作。
pre-requisites
JDK v1.8 or higher
SDK v2.2.1 or higher
NDK r10d or higher (Note: remember to export NDK's path)
Android Studio (with SDK) 1.2.1 or higher