Android mupdf java.lang.UnsatisfiedLinkError:dlopen失败:找不到符号" atof"

时间:2016-07-13 05:21:54

标签: java android pdf fatal-error mupdf

我正在使用mupdf在我的Android应用程序中打开一个pdf文件。该应用程序因此错误而崩溃。

  

java.lang.UnsatisfiedLinkError:dlopen失败:找不到符号   " ATOF"由" libmupdf_java.so" ...

引用

这是我查看pdf文件的java代码。

public class MainActivity extends AppCompatActivity {

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

        RelativeLayout layout = (RelativeLayout) findViewById(R.id.main_layout);

        MuPDFCore core = null;
        try {
            core = new MuPDFCore(this,"/storage/emulated/0/Download/Metamorphosis-jackson.pdf");
        } catch (Exception e) {
            e.printStackTrace();
        }
        MuPDFReaderView reader = new MuPDFReaderView(this);
        reader.setAdapter(new MuPDFPageAdapter(this, new FilePicker.FilePickerSupport() {
            @Override
            public void performPickFor(FilePicker filePicker) {

            }
        }, core ));
        layout.addView(reader);
    }
}

代码在此特定行崩溃。

  core = new MuPDFCore(this,"/storage/emulated/0/Download/Metamorphosis-jackson.pdf");

这是错误日志: -

  

07-13 10:40:34.299 7115-7115 / com.androidnewbee.www.shatayushiapp   E / AndroidRuntime:致命异常:主要                                                                                      过程:com.androidnewbee.www.shatayushiapp,PID:7115                                                                                      java.lang.UnsatisfiedLinkError:dlopen失败:找不到符号   " ATOF"由" libmupdf_java.so引用" ...                                                                                          在java.lang.Runtime.loadLibrary(Runtime.java:364)                                                                                          在java.lang.System.loadLibrary(System.java:526)                                                                                          在com.artifex.mupdfdemo.MuPDFCore。(MuPDFCore.java:15)                                                                                          在   com.androidnewbee.www.shatayushiapp.MainActivity.onCreate(MainActivity.java:23)                                                                                          在android.app.Activity.performCreate(Activity.java:5301)                                                                                          在   android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)                                                                                          在   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2291)                                                                                          在   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)                                                                                          在android.app.ActivityThread.access $ 800(ActivityThread.java:155)                                                                                          在   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1244)                                                                                          在android.os.Handler.dispatchMessage(Handler.java:102)                                                                                          在android.os.Looper.loop(Looper.java:136)                                                                                          在android.app.ActivityThread.main(ActivityThread.java:5433)                                                                                          at java.lang.reflect.Method.invokeNative(Native Method)                                                                                          在java.lang.reflect.Method.invoke(Method.java:515)                                                                                          在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1268)                                                                                          在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)                                                                                          在dalvik.system.NativeStart.main(本地方法)

此外,我想知道如何在列表中显示所有pdf文件,并允许用户从使用mupdf查看的文件中进行选择。 我是编程新手,所以欢迎任何帮助或建议。

1 个答案:

答案 0 :(得分:3)

谷歌已经将一些C标准库函数(如atof())从头文件中的内联函数转移到普通函数。最新的NDK将默认构建.so,它仅与在设备的标准C库(libc.so)中具有atof()函数的最新Android设备兼容。这意味着如果您在具有较旧版本C库的旧设备上运行库,则在加载dll时会出现错误,因为预期的atof()函数将不存在。

您是否尝试在Application.mk中设置此项:

APP_PLATFORM := android-9

这将使ndk编译器构建与旧版Android兼容的代码。

您还可以尝试将NDK安装降级到版本10b(此版本在更改之前,其中atof从内联移动到libc的一部分,因此完全避免了问题。)