无法在Android应用程序中加载本机库

时间:2017-01-11 12:01:22

标签: android android-ndk java-native-interface linphone

我在我的android应用程序中使用jar(linphone.jar)。这个jar有一个lib文件夹,其中包含.so文件夹(armeabi,armeabi-v7a,x86)。我运行我的应用程序时收到错误。我已经验证libgnustl_shared.so文件位于armeabi文件夹中,但是应用程序崩溃时出现以下错误:

01-11 12:49:30.791 10484-10606/? E/ACRA: ACRA caught a UnsatisfiedLinkError for com.myapp.hp.testApp
                                     java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.myapp.hp.testApp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myapp.hp.testApp-1/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libgnustl_shared.so"
                                         at java.lang.Runtime.loadLibrary(Runtime.java:366)
                                         at java.lang.System.loadLibrary(System.java:988)
                                         at org.linphone.core.LinphoneCoreFactoryImpl.<clinit>(LinphoneCoreFactoryImpl.java:51)
                                         at java.lang.Class.classForName(Native Method)
                                         at java.lang.Class.forName(Class.java:309)
                                         at java.lang.Class.forName(Class.java:273)
                                         at org.linphone.core.LinphoneCoreFactory.instance(LinphoneCoreFactory.java:47)
                                         at com.myapp.hp.testApp.sip.LinphoneManager.register(LinphoneManager.java:74)
                                         at com.myapp.hp.testApp.service.SipService.login(SipService.java:70)
                                         at com.myapp.hp.testApp.plugin.SipHandler$2.execute(SipHandler.java:83)
                                         at com.myapp.hp.testApp.plugin.SipHandler$2.execute(SipHandler.java:72)
                                         at com.myapp.hp.testApp.plugin.Executable$AbstractExecutable$1.run(Executable.java:36)
                                         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                         at java.lang.Thread.run(Thread.java:818)

有人可以建议我如何解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

在Android Studio 1.0.2中添加.so库

1.Create Folder&#34; jniLibs&#34;在里面&#34; src / main /&#34; 2.将所有.so库放在&#34; src / main / jniLibs&#34;夹 3.文件夹结构看起来像,

| --app:

| - | --src:

| - | - | --main

| - | - | - | --jniLibs

| - | - | - | - | --armeabi

| - | - | - | - | - | - 。so Files

| - | - | - | - | --x86

| - | - | - | - | - | - 。so Files

没有额外的代码只需同步您的项目并运行您的应用程序。

参考 https://github.com/commonsguy/sqlcipher-gradle/tree/master/src/main