我想添加一个库(PDFBox: http://pdfbox.apache.org/download.html).但我想我做错了什么。我做了:项目>属性>java构建路径>添加外部Jar>pdfbox-1.7.0。罐子。但是每当我在模拟器中启动我的项目时,我都会收到这个错误(logcat)

07-28 08:08:51.793: D/ddm-heap(222): Got feature list request
07-28 08:08:57.413: I/dalvikvm(222): Could not find method org.apache.pdfbox.pdmodel.PDDocument.load, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:08:57.413: W/dalvikvm(222): VFY: unable to resolve static method 3152: Lorg/apache/pdfbox/pdmodel/PDDocument;.load (Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;
07-28 08:08:57.413: D/dalvikvm(222): VFY: replacing opcode 0x71 at 0x0003
07-28 08:08:57.413: D/dalvikvm(222): Making a copy of Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;.doInBackground code (169 bytes)
07-28 08:08:57.423: E/dalvikvm(222): Could not find class 'org.apache.pdfbox.util.PDFTextStripper', referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:08:57.423: W/dalvikvm(222): VFY: unable to resolve new-instance 507 (Lorg/apache/pdfbox/util/PDFTextStripper;) in Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;
07-28 08:08:57.423: D/dalvikvm(222): VFY: replacing opcode 0x22 at 0x0008
07-28 08:08:57.423: I/dalvikvm(222): Could not find method org.apache.pdfbox.util.PDFTextStripper.getText, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:08:57.423: W/dalvikvm(222): VFY: unable to resolve virtual method 3154: Lorg/apache/pdfbox/util/PDFTextStripper;.getText (Lorg/apache/pdfbox/pdmodel/PDDocument;)Ljava/lang/String;
07-28 08:08:57.423: D/dalvikvm(222): VFY: replacing opcode 0x6e at 0x000e
07-28 08:08:57.433: I/dalvikvm(222): Could not find method org.apache.pdfbox.pdmodel.PDDocument.close, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:08:57.433: W/dalvikvm(222): VFY: unable to resolve virtual method 3151: Lorg/apache/pdfbox/pdmodel/PDDocument;.close ()V
07-28 08:08:57.433: D/dalvikvm(222): VFY: replacing opcode 0x6e at 0x001b
07-28 08:08:57.473: W/dalvikvm(222): threadid=15: thread exiting with uncaught exception (group=0x4001b188)
07-28 08:08:57.473: E/AndroidRuntime(222): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
07-28 08:08:57.483: E/AndroidRuntime(222): java.lang.RuntimeException: An error occured while executing doInBackground()
07-28 08:08:57.483: E/AndroidRuntime(222):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.lang.Thread.run(Thread.java:1096)
07-28 08:08:57.483: E/AndroidRuntime(222): Caused by: java.lang.NoClassDefFoundError: org.apache.pdfbox.pdmodel.PDDocument
07-28 08:08:57.483: E/AndroidRuntime(222):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:66)
07-28 08:08:57.483: E/AndroidRuntime(222):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:1)
07-28 08:08:57.483: E/AndroidRuntime(222):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-28 08:08:57.483: E/AndroidRuntime(222):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-28 08:08:57.483: E/AndroidRuntime(222):  ... 4 more
07-28 08:08:57.903: I/dalvikvm(222): threadid=7: reacting to signal 3
07-28 08:08:58.195: I/dalvikvm(222): Wrote stack trace to '/data/anr/traces.txt'
07-28 08:09:01.793: I/Process(222): Sending signal. PID: 222 SIG: 9
07-28 08:20:54.283: I/dalvikvm(249): Could not find method org.apache.pdfbox.pdmodel.PDDocument.load, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:20:54.293: W/dalvikvm(249): VFY: unable to resolve static method 3152: Lorg/apache/pdfbox/pdmodel/PDDocument;.load (Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;
07-28 08:20:54.293: D/dalvikvm(249): VFY: replacing opcode 0x71 at 0x0003
07-28 08:20:54.293: D/dalvikvm(249): Making a copy of Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;.doInBackground code (169 bytes)
07-28 08:20:54.293: E/dalvikvm(249): Could not find class 'org.apache.pdfbox.util.PDFTextStripper', referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:20:54.293: W/dalvikvm(249): VFY: unable to resolve new-instance 507 (Lorg/apache/pdfbox/util/PDFTextStripper;) in Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;
07-28 08:20:54.293: D/dalvikvm(249): VFY: replacing opcode 0x22 at 0x0008
07-28 08:20:54.293: I/dalvikvm(249): Could not find method org.apache.pdfbox.util.PDFTextStripper.getText, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:20:54.293: W/dalvikvm(249): VFY: unable to resolve virtual method 3154: Lorg/apache/pdfbox/util/PDFTextStripper;.getText (Lorg/apache/pdfbox/pdmodel/PDDocument;)Ljava/lang/String;
07-28 08:20:54.303: D/dalvikvm(249): VFY: replacing opcode 0x6e at 0x000e
07-28 08:20:54.303: I/dalvikvm(249): Could not find method org.apache.pdfbox.pdmodel.PDDocument.close, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:20:54.303: W/dalvikvm(249): VFY: unable to resolve virtual method 3151: Lorg/apache/pdfbox/pdmodel/PDDocument;.close ()V
07-28 08:20:54.303: D/dalvikvm(249): VFY: replacing opcode 0x6e at 0x001b
07-28 08:20:54.343: W/dalvikvm(249): threadid=15: thread exiting with uncaught exception (group=0x4001b188)
07-28 08:20:54.343: E/AndroidRuntime(249): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
07-28 08:20:54.383: E/AndroidRuntime(249): java.lang.RuntimeException: An error occured while executing doInBackground()
07-28 08:20:54.383: E/AndroidRuntime(249):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.lang.Thread.run(Thread.java:1096)
07-28 08:20:54.383: E/AndroidRuntime(249): Caused by: java.lang.NoClassDefFoundError: org.apache.pdfbox.pdmodel.PDDocument
07-28 08:20:54.383: E/AndroidRuntime(249):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:66)
07-28 08:20:54.383: E/AndroidRuntime(249):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:1)
07-28 08:20:54.383: E/AndroidRuntime(249):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-28 08:20:54.383: E/AndroidRuntime(249):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-28 08:20:54.383: E/AndroidRuntime(249):  ... 4 more
07-28 08:20:54.593: I/dalvikvm(249): threadid=7: reacting to signal 3
07-28 08:20:54.933: I/dalvikvm(249): Wrote stack trace to '/data/anr/traces.txt'
07-28 08:22:02.364: I/dalvikvm(273): Could not find method org.apache.pdfbox.pdmodel.PDDocument.load, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:22:02.374: W/dalvikvm(273): VFY: unable to resolve static method 3152: Lorg/apache/pdfbox/pdmodel/PDDocument;.load (Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;
07-28 08:22:02.374: D/dalvikvm(273): VFY: replacing opcode 0x71 at 0x0003
07-28 08:22:02.374: D/dalvikvm(273): Making a copy of Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;.doInBackground code (169 bytes)
07-28 08:22:02.374: E/dalvikvm(273): Could not find class 'org.apache.pdfbox.util.PDFTextStripper', referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:22:02.374: W/dalvikvm(273): VFY: unable to resolve new-instance 507 (Lorg/apache/pdfbox/util/PDFTextStripper;) in Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;
07-28 08:22:02.374: D/dalvikvm(273): VFY: replacing opcode 0x22 at 0x0008
07-28 08:22:02.374: I/dalvikvm(273): Could not find method org.apache.pdfbox.util.PDFTextStripper.getText, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:22:02.374: W/dalvikvm(273): VFY: unable to resolve virtual method 3154: Lorg/apache/pdfbox/util/PDFTextStripper;.getText (Lorg/apache/pdfbox/pdmodel/PDDocument;)Ljava/lang/String;
07-28 08:22:02.384: D/dalvikvm(273): VFY: replacing opcode 0x6e at 0x000e
07-28 08:22:02.384: I/dalvikvm(273): Could not find method org.apache.pdfbox.pdmodel.PDDocument.close, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:22:02.384: W/dalvikvm(273): VFY: unable to resolve virtual method 3151: Lorg/apache/pdfbox/pdmodel/PDDocument;.close ()V
07-28 08:22:02.384: D/dalvikvm(273): VFY: replacing opcode 0x6e at 0x001b
07-28 08:22:02.424: W/dalvikvm(273): threadid=15: thread exiting with uncaught exception (group=0x4001b188)
07-28 08:22:02.424: E/AndroidRuntime(273): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
07-28 08:22:02.554: E/AndroidRuntime(273): java.lang.RuntimeException: An error occured while executing doInBackground()
07-28 08:22:02.554: E/AndroidRuntime(273):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.lang.Thread.run(Thread.java:1096)
07-28 08:22:02.554: E/AndroidRuntime(273): Caused by: java.lang.NoClassDefFoundError: org.apache.pdfbox.pdmodel.PDDocument
07-28 08:22:02.554: E/AndroidRuntime(273):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:66)
07-28 08:22:02.554: E/AndroidRuntime(273):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:1)
07-28 08:22:02.554: E/AndroidRuntime(273):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-28 08:22:02.554: E/AndroidRuntime(273):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-28 08:22:02.554: E/AndroidRuntime(273):  ... 4 more
07-28 08:22:02.664: I/dalvikvm(273): threadid=7: reacting to signal 3
07-28 08:22:02.924: I/dalvikvm(273): Wrote stack trace to '/data/anr/traces.txt'
07-28 08:22:05.184: I/Process(273): Sending signal. PID: 273 SIG: 9
07-28 08:33:06.073: I/dalvikvm(300): Could not find method org.apache.pdfbox.pdmodel.PDDocument.load, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:33:06.073: W/dalvikvm(300): VFY: unable to resolve static method 3152: Lorg/apache/pdfbox/pdmodel/PDDocument;.load (Ljava/lang/String;)Lorg/apache/pdfbox/pdmodel/PDDocument;
07-28 08:33:06.073: D/dalvikvm(300): VFY: replacing opcode 0x71 at 0x0003
07-28 08:33:06.073: D/dalvikvm(300): Making a copy of Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;.doInBackground code (169 bytes)
07-28 08:33:06.073: E/dalvikvm(300): Could not find class 'org.apache.pdfbox.util.PDFTextStripper', referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:33:06.073: W/dalvikvm(300): VFY: unable to resolve new-instance 507 (Lorg/apache/pdfbox/util/PDFTextStripper;) in Lme/moop/mytwitter/MainActivity$CheckScheduleChangeTask;
07-28 08:33:06.073: D/dalvikvm(300): VFY: replacing opcode 0x22 at 0x0008
07-28 08:33:06.083: I/dalvikvm(300): Could not find method org.apache.pdfbox.util.PDFTextStripper.getText, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:33:06.083: W/dalvikvm(300): VFY: unable to resolve virtual method 3154: Lorg/apache/pdfbox/util/PDFTextStripper;.getText (Lorg/apache/pdfbox/pdmodel/PDDocument;)Ljava/lang/String;
07-28 08:33:06.083: D/dalvikvm(300): VFY: replacing opcode 0x6e at 0x000e
07-28 08:33:06.083: I/dalvikvm(300): Could not find method org.apache.pdfbox.pdmodel.PDDocument.close, referenced from method me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground
07-28 08:33:06.083: W/dalvikvm(300): VFY: unable to resolve virtual method 3151: Lorg/apache/pdfbox/pdmodel/PDDocument;.close ()V
07-28 08:33:06.083: D/dalvikvm(300): VFY: replacing opcode 0x6e at 0x001b
07-28 08:33:06.123: W/dalvikvm(300): threadid=15: thread exiting with uncaught exception (group=0x4001b188)
07-28 08:33:06.123: E/AndroidRuntime(300): Uncaught handler: thread AsyncTask #1 exiting due to uncaught exception
07-28 08:33:06.135: E/AndroidRuntime(300): java.lang.RuntimeException: An error occured while executing doInBackground()
07-28 08:33:06.135: E/AndroidRuntime(300):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.lang.Thread.run(Thread.java:1096)
07-28 08:33:06.135: E/AndroidRuntime(300): Caused by: java.lang.NoClassDefFoundError: org.apache.pdfbox.pdmodel.PDDocument
07-28 08:33:06.135: E/AndroidRuntime(300):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:66)
07-28 08:33:06.135: E/AndroidRuntime(300):  at me.moop.mytwitter.MainActivity$CheckScheduleChangeTask.doInBackground(MainActivity.java:1)
07-28 08:33:06.135: E/AndroidRuntime(300):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-28 08:33:06.135: E/AndroidRuntime(300):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-28 08:33:06.135: E/AndroidRuntime(300):  ... 4 more
07-28 08:33:06.453: I/dalvikvm(300): threadid=7: reacting to signal 3
07-28 08:33:06.623: I/dalvikvm(300): Wrote stack trace to '/data/anr/traces.txt'
07-28 08:33:08.723: I/Process(300): Sending signal. PID: 300 SIG: 9

所以它找不到我从aditional库导入的类。当我打开的时候。jar在java构建路径屏幕它说这:

源附件:(无)

Javadoc位置:(无)

本地图书馆位置:(无)

访问规则:(没有限制)

这正常吗?

任何人都可以告诉我我需要从该网站下载哪些文件(http://pdfbox.apache.org/download.html)以及我必须在哪个屏幕以及如何添加哪些文件。

谢谢!

有帮助吗?

解决方案

从ADT r17开始,您不应该再像这样将库文件添加到项目中。这现在由ADT自动处理。

为了将外部库添加到您的项目中,您必须创建一个名为 libs 在项目的根文件夹中(您的 src 文件夹所在)。下一步是将所有库(jar)复制到该文件夹。其余的是自动为您完成的。无需编辑构建路径等。

其他提示

好友尝试这种方式

Right click on Yout project  -> Click on New -> goto Folder -> Give Folder name
.

libs文件夹中添加 .jars

Right click on res folder -> Goto Build path -> click on Add External jar
.

Right click on res folder -> Goto Build path -> Configure build path -> From Left side menu Select "Java Build path" ->There will be 4 tabs Click on Libraries -> Click on Add Externals JARs..
.

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