android静态库坏ELF号

时间:2016-06-02 15:15:04

标签: android static numbers elf

我已经使用Android ndk构建了一个静态库。

我现在尝试在另一个Android项目中使用此库

//in mainActivity
static
{
    System.loadLibrary("MILlib");
}

构建测试项目时出现以下错误

  

02 17:07:24.890 2785-2785 / com.MIL.testlib E / AndroidRuntime:FATAL EXCEPTION:main                                                                  过程:com.MIL.testlib,PID:2785                                                                  java.lang.UnsatisfiedLinkError:dlopen失败:“/ data / app / com.MIL.testlib-1 / lib / arm / libMILlib.so”有错误的ELF魔法                                                                      在java.lang.Runtime.loadLibrary(Runtime.java:371)                                                                      在java.lang.System.loadLibrary(System.java:989)                                                                      在com.MIL.testlib.MainActivity。(MainActivity.java:112)                                                                      at java.lang.reflect.Constructor.newInstance(Native Method)                                                                      在java.lang.Class.newInstance(Class.java:1650)                                                                      在android.app.Instrumentation.newActivity(Instrumentation.java:1079)                                                                      在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2640)                                                                      在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)                                                                      在android.app.ActivityThread.access $ 900(ActivityThread.java:181)                                                                      在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1482)                                                                      在android.os.Handler.dispatchMessage(Handler.java:102)                                                                      在android.os.Looper.loop(Looper.java:145)                                                                      在android.app.ActivityThread.main(ActivityThread.java:6145)                                                                      at java.lang.reflect.Method.invoke(Native Method)                                                                      在java.lang.reflect.Method.invoke(Method.java:372)                                                                      在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1399)                                                                      在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

什么是错误的ELF幻数以及如何解决它?

1 个答案:

答案 0 :(得分:5)

.so对象是共享对象文件。这是本机代码而不是Java库,它被称为ELF,因为它是可扩展链接格式。

"魔法"是指ELF文件的前64位。这指定了一些标头信息,包括为其构建的系统的体系结构。

Android手机支持三种架构:ARM,Intel和MIPS。仿真器支持它们运行的​​硬件,通常是Intel。鉴于您的.so已拥有' arm'在目录路径中,我怀疑您的.so是ARM .so,并且您尝试在英特尔或MIPS上运行此功能。