user446010
user446010

Reputation: 79

APV PDF Viewer crash

I am new to Android NDK. This is my first project. I downloaded android PDF reader from http://code.google.com/p/apv/downloads/list. It's compiling properly, but when I tried to load PDF from this app. It's showing below error:

07-03 10:18:06.171: ERROR/AndroidRuntime(375): FATAL EXCEPTION: main
07-03 10:18:06.171: ERROR/AndroidRuntime(375): java.lang.ExceptionInInitializerError
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at cx.hell.android.pdfview.OpenFileActivity.getPDF(OpenFileActivity.java:541)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at cx.hell.android.pdfview.OpenFileActivity.startPDF(OpenFileActivity.java:502)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at cx.hell.android.pdfview.OpenFileActivity.onCreate(OpenFileActivity.java:219)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.os.Looper.loop(Looper.java:123)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at java.lang.reflect.Method.invokeNative(Native Method)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at java.lang.reflect.Method.invoke(Method.java:521)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at dalvik.system.NativeStart.main(Native Method)
07-03 10:18:06.171: ERROR/AndroidRuntime(375): Caused by: java.lang.UnsatisfiedLinkError: Library pdfview2 not found
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at java.lang.Runtime.loadLibrary(Runtime.java:461)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at java.lang.System.loadLibrary(System.java:557)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     at cx.hell.android.lib.pdf.PDF.<clinit>(PDF.java:25)
07-03 10:18:06.171: ERROR/AndroidRuntime(375):     ... 16 more

I saw a similar error in so many questions. Since I am new to NDK, I couldn't understand what to do.

Upvotes: 2

Views: 1142

Answers (4)

Phil
Phil

Reputation: 36299

You get this error when you don't load the native library. This will happen for a lot of reasons. First, you need to make sure your Android.mk file (in your jni directory) is set up properly. Assuming it (or they) are set up correctly, find the line that looks something like this:

LOCAL_MODULE := libpdfview2

Note the name of this, as it is important. Next, add the following lines to the top of your Activity (or Application in a multi-Activity app):

static {
    System.loadLibrary("pdfview2");
}

Here, note the name. It is the name of the local module with the lib prefix removed. Assuming the NDK build works, and the Android.mk files are set up correctly, this will solve your issue.


Edit

Also, have you read the info about building the library, here?

Upvotes: 2

Dinesh Prajapati
Dinesh Prajapati

Reputation: 9520

Caused by: java.lang.UnsatisfiedLinkError: Library pdfview2 not found

The above exception is caused due to link is not found for the specified library which is self explanatory but actually reason is when the .so file of the related project has been created from the project the .so functions are created according the package structure of the project. so we can not directly use that .so in our project.

you need to re-build the .so file with your application package and after that this error will not be valid and you will be able to get the native function access too.

Upvotes: 1

KyelJmD
KyelJmD

Reputation: 4732

Looks like this caused the error Caused by: java.lang.UnsatisfiedLinkError: Library pdfview2 not found

Just download this library, pdfview2

open the file using any zip tool and copy the necessary files in your project and you are good to go.

Upvotes: 4

g00dy
g00dy

Reputation: 6788

There's another solution for PDF opening, take a peek here:

Open PDF in Android

I think that without your code it will be difficult to imagine what's happening.

Upvotes: 1

Related Questions