无法使用JoanZapata android-pdfview -app崩溃显示pdf

时间:2015-11-20 12:24:25

标签: android pdf

我正在开发一个Android应用程序,我想在同一个应用程序中显示pdf,所以我下载了最新的android-pdfview-1.0.4.jar from here,我还下载了所有必需的库,如图所示从这里下面github.com/JoanZapata/android-pdfview/tree/master/android-pdfview/libs

enter image description here

这是我的MainActivity.java

public class MainActivity extends Activity implements OnLoadCompleteListener, OnPageChangeListener, OnDrawListener {

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

        PDFView pdfView= (PDFView) findViewById(R.id.pdfview);

        pdfView.fromAsset("sample.pdf")
                .defaultPage(1)
                .showMinimap(false)
                .enableSwipe(true)
                .onLoad(this)
                .onPageChange(this)
                .load();;
    }



    @Override
    public void loadComplete(int i) {

    }

    @Override
    public void onPageChanged(int i, int i1) {

    }

    @Override
    public void onLayerDrawn(Canvas canvas, float v, float v1, int i) {

    }
}

这是我的activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:tools="http://schemas.android.com/tools"
             android:layout_width="match_parent"
             android:layout_height="match_parent" >

    <com.joanzapata.pdfview.PDFView
        android:id="@+id/pdfview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

我还在我的Build.gradle文件中添加了所需的依赖项

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile files('libs/android-pdfview-1.0.4.jar')
}

我还添加了assets folder并在其中添加了一个pdf - sample.pdf

现在,每当我尝试运行我的应用程序时,应用程序都会崩溃

11-20 17:48:42.000  14517-14526/? E/art﹕ Failed sending reply to debugger: Broken pipe
11-20 17:48:42.000  14517-14526/? I/art﹕ Debugger is no longer active
11-20 17:48:42.126  14517-14536/? E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: com.test.pdf, PID: 14517
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:304)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.test.pdf-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libvudroid.so"
            at java.lang.Runtime.loadLibrary(Runtime.java:366)
            at java.lang.System.loadLibrary(System.java:988)
            at org.vudroid.core.VuDroidLibraryLoader.load(VuDroidLibraryLoader.java:13)
            at org.vudroid.pdfdroid.codec.PdfContext.<clinit>(PdfContext.java:13)
            at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:50)
            at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:31)
            at android.os.AsyncTask$2.call(AsyncTask.java:292)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)

请帮忙。

0 个答案:

没有答案