i was implmenting a pdf reader in my project when i got the following error..

E/AndroidRuntime(1495): FATAL EXCEPTION: main
E/AndroidRuntime(1495): Process: com.example.testqstn, PID: 1495
E/AndroidRuntime(1495): java.lang.NoClassDefFoundError: com.questionpoint.pdf.Pdf
E/AndroidRuntime(1495):     at com.question_point.main.Question_Point_Main.openPdfIntent(Question_Point_Main.java:272)
E/AndroidRuntime(1495):     at com.question_point.main.Question_Point_Main.CopyReadAssets(Question_Point_Main.java:266)
E/AndroidRuntime(1495):     at com.question_point.main.Question_Point_Main.pdfSelection(Question_Point_Main.java:128)
E/AndroidRuntime(1495):     at com.question_point.main.Question_Point_Main$2.onClick(Question_Point_Main.java:104)
E/AndroidRuntime(1495):     at android.view.View.performClick(View.java:4438)
E/AndroidRuntime(1495):     at android.view.View$PerformClick.run(View.java:18422)
E/AndroidRuntime(1495):     at android.os.Handler.handleCallback(Handler.java:733)
E/AndroidRuntime(1495):     at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(1495):     at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(1495):     at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime(1495):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(1495):     at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(1495):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime(1495):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime(1495):     at dalvik.system.NativeStart.main(Native Method)
I/Process(1495): Sending signal. PID: 1495 SIG: 9

i had imported a project to my code.. my library file is named libs, and i have repeatedly cleaned my project.. but still the error persists.. Thanks in advance..

The code that leads to error

 public void CopyReadAssets(String url) {
      AssetManager assetManager = getAssets();
      InputStream in = null;
      OutputStream out = null;
      File file = new File(getFilesDir(), url);
      try {
               in = assetManager.open(url);
               out = openFileOutput(file.getName(),
               Context.MODE_WORLD_READABLE);

               copyFile(in, out);
               in.close();
               in = null;
               out.flush();
               out.close();
               out = null;
      } 
      catch (Exception e) {
       Log.e("tag", e.getMessage());
      }
      String path = "file://" + getFilesDir() + "/"+url;
      openPdfIntent(path);

}

private void openPdfIntent(String path) {
    // TODO Auto-generated method stub
     try {
            final Intent intent = new Intent(Question_Point_Main.this, Pdf.class);
            intent.putExtra(PdfViewerActivity.EXTRA_PDFFILENAME, path);
            startActivity(intent);
        } catch (Exception e) {
            e.printStackTrace();
        }
}
有帮助吗?

解决方案

Try these steps:

Step 1: Create a folder "lib", and copy all third-party jars here;

Step 2: Add these jars to build path;

Step 3: Use the folder as Source Folder(shown below).

step 3

其他提示

Maybe you just forgot the underscore and you meant com.question_point.pdf.Pdf?

It would be easier to tell if you could post the relevant code where you make the call that leads to the Exception.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top