在android应用程序中使用.so库时出错

时间:2013-08-26 06:14:45

标签: android sdk android-ndk shared-libraries audio

我想在我的android应用程序中使用.so库(http://illiri.com/api.html)。我已将.so文件复制到libs文件夹(libs / armeabi,libs / armeabi-v7a,libs / mips,libs / x86),并将库加载为,

System.loadLibrary("crypto");
System.loadLibrary("ssl");
System.loadLibrary("sapi");

但我在堆栈跟踪中遇到此错误。

    08-26 11:17:24.677: E/dalvikvm(25747): Could not find class 'com.illiri.sapi.SAPIConnection', referenced from method com.ey.illiritest.MainActivity.onCreate
    08-26 11:17:24.697: W/dalvikvm(25747): VFY: unable to resolve new-instance 474 (Lcom/illiri/sapi/SAPIConnection;) in Lcom/ey/illiritest/MainActivity;
    08-26 11:17:24.697: D/dalvikvm(25747): VFY: replacing opcode 0x22 at 0x000b
    08-26 11:17:24.697: D/dalvikvm(25747): VFY: dead code 0x000d-0030 in Lcom/ey/illiritest/MainActivity;.onCreate (Landroid/os/Bundle;)V
    08-26 11:17:24.697: I/dalvikvm(25747): Could not find method com.illiri.sapi.SAPIConnection.suspend, referenced from method com.ey.illiritest.MainActivity.onPause
    08-26 11:17:24.697: W/dalvikvm(25747): VFY: unable to resolve virtual method 3424: Lcom/illiri/sapi/SAPIConnection;.suspend ()V
    08-26 11:17:24.697: D/dalvikvm(25747): VFY: replacing opcode 0x6e at 0x0005
    08-26 11:17:24.697: D/dalvikvm(25747): VFY: dead code 0x0008-0008 in Lcom/ey/illiritest/MainActivity;.onPause ()V
    08-26 11:17:24.707: I/dalvikvm(25747): Could not find method com.illiri.sapi.SAPIConnection.resume, referenced from method com.ey.illiritest.MainActivity.onResume
    08-26 11:17:24.707: W/dalvikvm(25747): VFY: unable to resolve virtual method 3423: Lcom/illiri/sapi/SAPIConnection;.resume ()V
    08-26 11:17:24.707: D/dalvikvm(25747): VFY: replacing opcode 0x6e at 0x0005
    08-26 11:17:24.707: D/dalvikvm(25747): VFY: dead code 0x0008-0008 in Lcom/ey/illiritest/MainActivity;.onResume ()V
    08-26 11:17:24.707: D/dalvikvm(25747): Trying to load lib /mnt/asec/com.ey.illiritest-1/lib/libcrypto.so 0x2afcad60
    08-26 11:17:24.707: D/dalvikvm(25747): Added shared lib /mnt/asec/com.ey.illiritest-1/lib/libcrypto.so 0x2afcad60
    08-26 11:17:24.707: D/dalvikvm(25747): No JNI_OnLoad found in /mnt/asec/com.ey.illiritest-1/lib/libcrypto.so 0x2afcad60, skipping init
    08-26 11:17:24.707: D/dalvikvm(25747): Trying to load lib /mnt/asec/com.ey.illiritest-1/lib/libssl.so 0x2afcad60
    08-26 11:17:24.707: D/dalvikvm(25747): Added shared lib /mnt/asec/com.ey.illiritest-1/lib/libssl.so 0x2afcad60
    08-26 11:17:24.707: D/dalvikvm(25747): No JNI_OnLoad found in /mnt/asec/com.ey.illiritest-1/lib/libssl.so 0x2afcad60, skipping init
    08-26 11:17:24.707: D/dalvikvm(25747): Trying to load lib /mnt/asec/com.ey.illiritest-1/lib/libsapi.so 0x2afcad60
    08-26 11:17:24.827: W/dalvikvm(25747): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/ey/illiritest/MainActivity;
    08-26 11:17:24.837: W/dalvikvm(25747): Class init failed in newInstance call (Lcom/ey/illiritest/MainActivity;)
    08-26 11:17:24.837: D/AndroidRuntime(25747): Shutting down VM
    08-26 11:17:24.847: W/dalvikvm(25747): threadid=1: thread exiting with uncaught exception (group=0x2aacc560)
    08-26 11:17:24.847: E/AndroidRuntime(25747): Uncaught handler: thread main exiting due to uncaught exception
    08-26 11:17:24.937: W/System.err(25747): java.io.IOException: Permission denied
    08-26 11:17:24.937: E/AndroidRuntime(25747): FATAL EXCEPTION: main
    08-26 11:17:24.937: E/AndroidRuntime(25747): java.lang.ExceptionInInitializerError
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at java.lang.Class.newInstanceImpl(Native Method)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at java.lang.Class.newInstance(Class.java:1409)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.os.Handler.dispatchMessage(Handler.java:99)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.os.Looper.loop(Looper.java:130)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at android.app.ActivityThread.main(ActivityThread.java:3683)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at java.lang.reflect.Method.invokeNative(Native Method)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at java.lang.reflect.Method.invoke(Method.java:507)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at dalvik.system.NativeStart.main(Native Method)
    08-26 11:17:24.937: E/AndroidRuntime(25747): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1311]:  1376 cannot locate '__gnu_thumb1_case_uqi'...
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at java.lang.Runtime.loadLibrary(Runtime.java:434)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at java.lang.System.loadLibrary(System.java:554)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    at com.ey.illiritest.MainActivity.<clinit>(MainActivity.java:167)
    08-26 11:17:24.937: E/AndroidRuntime(25747):    ... 15 more
    08-26 11:17:24.967: W/System.err(25747): java.io.FileNotFoundException: /data/plog.log (Permission denied)
    08-26 11:17:27.797: I/Process(25747): Sending signal. PID: 25747 SIG: 9
    08-26 11:18:46.837: E/dalvikvm(25943): Could not find class 'com.illiri.sapi.SAPIConnection', referenced from method com.ey.illiritest.MainActivity.onCreate
    08-26 11:18:46.837: W/dalvikvm(25943): VFY: unable to resolve new-instance 474 (Lcom/illiri/sapi/SAPIConnection;) in Lcom/ey/illiritest/MainActivity;
    08-26 11:18:46.837: D/dalvikvm(25943): VFY: replacing opcode 0x22 at 0x001a
    08-26 11:18:46.837: D/dalvikvm(25943): VFY: dead code 0x001c-003f in Lcom/ey/illiritest/MainActivity;.onCreate (Landroid/os/Bundle;)V
    08-26 11:18:46.837: I/dalvikvm(25943): Could not find method com.illiri.sapi.SAPIConnection.suspend, referenced from method com.ey.illiritest.MainActivity.onPause
    08-26 11:18:46.837: W/dalvikvm(25943): VFY: unable to resolve virtual method 3424: Lcom/illiri/sapi/SAPIConnection;.suspend ()V
    08-26 11:18:46.837: D/dalvikvm(25943): VFY: replacing opcode 0x6e at 0x0005
    08-26 11:18:46.837: D/dalvikvm(25943): VFY: dead code 0x0008-0008 in Lcom/ey/illiritest/MainActivity;.onPause ()V
    08-26 11:18:46.847: I/dalvikvm(25943): Could not find method com.illiri.sapi.SAPIConnection.resume, referenced from method com.ey.illiritest.MainActivity.onResume
    08-26 11:18:46.847: W/dalvikvm(25943): VFY: unable to resolve virtual method 3423: Lcom/illiri/sapi/SAPIConnection;.resume ()V
    08-26 11:18:46.847: D/dalvikvm(25943): VFY: replacing opcode 0x6e at 0x0005
    08-26 11:18:46.847: D/dalvikvm(25943): VFY: dead code 0x0008-0008 in Lcom/ey/illiritest/MainActivity;.onResume ()V
    08-26 11:18:46.877: D/dalvikvm(25943): Trying to load lib /mnt/asec/com.ey.illiritest-1/lib/libcrypto.so 0x2afcb300
    08-26 11:18:46.877: D/dalvikvm(25943): Added shared lib /mnt/asec/com.ey.illiritest-1/lib/libcrypto.so 0x2afcb300
    08-26 11:18:46.877: D/dalvikvm(25943): No JNI_OnLoad found in /mnt/asec/com.ey.illiritest-1/lib/libcrypto.so 0x2afcb300, skipping init
    08-26 11:18:46.877: D/dalvikvm(25943): Trying to load lib /mnt/asec/com.ey.illiritest-1/lib/libssl.so 0x2afcb300
    08-26 11:18:46.877: D/dalvikvm(25943): Added shared lib /mnt/asec/com.ey.illiritest-1/lib/libssl.so 0x2afcb300
    08-26 11:18:46.877: D/dalvikvm(25943): No JNI_OnLoad found in /mnt/asec/com.ey.illiritest-1/lib/libssl.so 0x2afcb300, skipping init
    08-26 11:18:46.877: D/dalvikvm(25943): Trying to load lib /mnt/asec/com.ey.illiritest-1/lib/libsapi.so 0x2afcb300
    08-26 11:18:46.927: D/AndroidRuntime(25943): Shutting down VM
    08-26 11:18:46.927: W/dalvikvm(25943): threadid=1: thread exiting with uncaught exception (group=0x2aacc560)
    08-26 11:18:46.927: E/AndroidRuntime(25943): Uncaught handler: thread main exiting due to uncaught exception
    08-26 11:18:46.957: W/System.err(25943): java.io.IOException: Permission denied
    08-26 11:18:46.967: E/AndroidRuntime(25943): FATAL EXCEPTION: main
    08-26 11:18:46.967: E/AndroidRuntime(25943): java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1311]:  1376 cannot locate '__gnu_thumb1_case_uqi'...
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at java.lang.Runtime.loadLibrary(Runtime.java:434)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at java.lang.System.loadLibrary(System.java:554)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at com.ey.illiritest.MainActivity.onCreate(MainActivity.java:36)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.os.Handler.dispatchMessage(Handler.java:99)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.os.Looper.loop(Looper.java:130)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at android.app.ActivityThread.main(ActivityThread.java:3683)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at java.lang.reflect.Method.invokeNative(Native Method)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at java.lang.reflect.Method.invoke(Method.java:507)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:895)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
    08-26 11:18:46.967: E/AndroidRuntime(25943):    at dalvik.system.NativeStart.main(Native Method)
    08-26 11:18:46.987: W/System.err(25943): java.io.FileNotFoundException: /data/plog.log (Permission denied)

我在互联网上搜索了很多,但却无法找到解决方案。请帮忙。

2 个答案:

答案 0 :(得分:0)

AFAIK,每当我们编译任何本机代码并使用android ndk的ndk-build命令生成* .so文件时,它都特定于特定的工具链。

现在,您在应用程序中下载和使用的库可能无法使用Android ndk支持的工具链进行构建。这是因为我在我的应用程序中使用它时出现类似错误的原因之一。

因此,请尝试由android系统支持的工具链生成的* .so文件。

答案 1 :(得分:0)

这是一个工具链问题(参见https://dev.guardianproject.info/issues/229) - 迫使NDK工具链到4.4.3似乎可以完成这项工作。