Nadim Iqbal Nadim Iqbal - 3 months ago 57
Android Question

Android Pdf Viewer FileNotFoundException

I am trying to show pdf file in my application. I am using Pdf Viewer library( I have put a pdf file in my assets folder. But when I try to load the file it shows this exception:

java.lang.RuntimeException: Unable to start activity ComponentInfo{}: com.github.barteksc.pdfviewer.exception.FileNotFoundException: src/main/assets/test does not exist

Here is my code:

com.github.barteksc.pdfviewer.PDFView pdfView=(com.github.barteksc.pdfviewer.PDFView) findViewById(;
pdfView.fromAsset("src/main/assets/test") //test is the pdf file name
.pages(0, 2, 1, 3, 3, 3) // all pages are displayed by default

Here is my permission in Manifest file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

I am using Ubuntu 12.04

Is there any way to solve this problem.

Thank you


Replace src/main/assets/test with test. src/main/assets/test is a relative path to this file on your development machine, not in the assets as packaged on the device.

Note that I assume that you manually removed the .pdf extension from the file when you put it in src/main/assets/. If that file still has the .pdf extension, you probably need it in your code. Resources drop their extensions; assets do not.