Android mupdf java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol “atof”

非 Y 不嫁゛ 提交于 2019-11-28 12:30:01

问题


I am using mupdf to open a pdf file in my android app.The app crashes with this error.

java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "atof" referenced by "libmupdf_java.so"...

This is my java code for viewing the pdf file.

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);
    }
}

The code crashes at this particular line.

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

This is the error log:-

07-13 10:40:34.299 7115-7115/com.androidnewbee.www.shatayushiapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.androidnewbee.www.shatayushiapp, PID: 7115 java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "atof" referenced by "libmupdf_java.so"... at java.lang.Runtime.loadLibrary(Runtime.java:364) at java.lang.System.loadLibrary(System.java:526) at com.artifex.mupdfdemo.MuPDFCore.(MuPDFCore.java:15) at com.androidnewbee.www.shatayushiapp.MainActivity.onCreate(MainActivity.java:23) at android.app.Activity.performCreate(Activity.java:5301) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2291) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378) at android.app.ActivityThread.access$800(ActivityThread.java:155) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5433) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) at dalvik.system.NativeStart.main(Native Method)

Also I would like to know how I can display all the pdf files in a list and allow the user to select from the files to view using mupdf. I am new to programming so any help or suggestion is welcome.


回答1:


Google have moved some of the C standard library functions like atof() from being inline functions in header files to normal functions. The latest NDKs will default to building a .so that is only compatible with the latest Android devices that have the atof() function in the device's standard C library (libc.so). This means if you run a library on an older device that has an older version of the C library, you will get an error loading the dll as the expected atof() function will not exist.

Have you tried setting this in your Application.mk:

APP_PLATFORM := android-9

This will cause the ndk compiler to build code compatible with older Android versions.

You can also try downgrading your NDK installation to version 10b (this version predates the change where atof was moved from inline to part of libc so avoids the problem entirely).



来源:https://stackoverflow.com/questions/38343219/android-mupdf-java-lang-unsatisfiedlinkerror-dlopen-failed-cannot-locate-symbo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!