Android-java.lang.NoClassDefFoundError:com.itextpdf.text.Document

Android-java.lang.NoClassDefFoundError:com.itextpdf.text.Document,java,android,itext,Java,Android,Itext,我正在使用eclipse,并尝试在我的Android应用程序中使用以下代码生成pdf文件 public void createPDF(View view){ //reference to EditText EditText et=(EditText)findViewById(R.id.txt_input); //create document object Document doc=new Document(); //output fi

我正在使用eclipse,并尝试在我的Android应用程序中使用以下代码生成pdf文件

public void createPDF(View view){
      //reference to EditText
      EditText et=(EditText)findViewById(R.id.txt_input);
      //create document object
      Document doc=new Document();
      //output file path
      String outpath=Environment.getExternalStorageDirectory()+"/storage/emulated/0/mypdf.pdf";
      try {
        //create pdf writer instance
        PdfWriter.getInstance(doc, new FileOutputStream(outpath));
        //open the document for writing
        doc.open();
        //add paragraph to the document
        doc.add(new Paragraph(et.getText().toString()));
        //close the document
        doc.close();
      } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } catch (DocumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
在LogCat中,当我执行应用程序时发生错误

java.lang.NoClassDefFoundError:com.itextpdf.text.Document
停止使用Eclipse或开始使用Gradle正确管理依赖关系停止使用Eclipse或开始使用Gradle正确管理依赖关系
-12 16:22:01.461: E/AndroidRuntime(14102): FATAL EXCEPTION: main
    02-12 16:22:01.461: E/AndroidRuntime(14102): Process: com.example.pdfandroid, PID: 14102
    02-12 16:22:01.461: E/AndroidRuntime(14102): java.lang.IllegalStateException: Could not execute method of the activity
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.view.View$1.onClick(View.java:3969)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.view.View.performClick(View.java:4640)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.view.View$PerformClick.run(View.java:19431)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.os.Handler.handleCallback(Handler.java:733)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.os.Handler.dispatchMessage(Handler.java:95)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.os.Looper.loop(Looper.java:146)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.app.ActivityThread.main(ActivityThread.java:5598)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at java.lang.reflect.Method.invokeNative(Native Method)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at java.lang.reflect.Method.invoke(Method.java:515)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at dalvik.system.NativeStart.main(Native Method)
    02-12 16:22:01.461: E/AndroidRuntime(14102): Caused by: java.lang.reflect.InvocationTargetException
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at java.lang.reflect.Method.invokeNative(Native Method)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at java.lang.reflect.Method.invoke(Method.java:515)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at android.view.View$1.onClick(View.java:3964)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    ... 11 more
    02-12 16:22:01.461: E/AndroidRuntime(14102): Caused by: java.lang.NoClassDefFoundError: com.itextpdf.text.Document
    02-12 16:22:01.461: E/AndroidRuntime(14102):    at com.example.pdfandroid.MainActivity.createPDF(MainActivity.java:36)
    02-12 16:22:01.461: E/AndroidRuntime(14102):    ... 14 more