我收到一个我不明白的错误。我要做的就是从pdf中提取文本。我正在使用droidText(http://code.google.com/p/droidtext/)这是代码:
public void parsePdf(URL pdf) throws IOException {
PdfReader reader = new PdfReader(pdf.openStream());
PdfTextExtractor pdfEx = new PdfTextExtractor(reader);
for(i=1; i <= reader.getNumberOfPages(); i++){
Scanner scanner = new Scanner(pdfEx.getTextFromPage(i));
while(scanner.hasNextLine()){
paragraphs.add(scanner.nextLine());
}
}
}
这是logcat:
05-01 17:04:37.059: D/dalvikvm(295): GC freed 4534 objects / 194136 bytes in 47ms
05-01 17:04:38.970: D/dalvikvm(295): GC freed 4416 objects / 411552 bytes in 62ms
05-01 17:04:38.980: I/dalvikvm-heap(295): Grow heap (frag case) to 5.906MB for 523658-byte allocation
05-01 17:04:39.049: D/dalvikvm(295): GC freed 334 objects / 15008 bytes in 64ms
05-01 17:04:39.371: D/dalvikvm(295): GC freed 504 objects / 284696 bytes in 50ms
05-01 17:04:39.380: I/dalvikvm-heap(295): Grow heap (frag case) to 6.625MB for 1054154-byte allocation
05-01 17:04:39.450: D/dalvikvm(295): GC freed 0 objects / 0 bytes in 74ms
05-01 17:04:39.520: D/dalvikvm(295): GC freed 1904 objects / 595384 bytes in 64ms
05-01 17:04:39.780: D/dalvikvm(295): GC freed 10610 objects / 1483240 bytes in 57ms
05-01 17:04:40.160: D/dalvikvm(295): GC freed 17834 objects / 808256 bytes in 62ms
05-01 17:04:40.610: D/dalvikvm(295): GC freed 20850 objects / 963048 bytes in 64ms
05-01 17:04:41.090: D/dalvikvm(295): GC freed 30108 objects / 1060848 bytes in 67ms
05-01 17:04:41.210: D/AndroidRuntime(295): Shutting down VM
05-01 17:04:41.210: W/dalvikvm(295): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
05-01 17:04:41.220: E/AndroidRuntime(295): Uncaught handler: thread main exiting due to uncaught exception
05-01 17:04:41.334: I/DEBUG(27): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-01 17:04:41.334: I/DEBUG(27): Build fingerprint: 'generic/sdk/generic/:2.1-update1/ECLAIR/35983:eng/test-keys'
05-01 17:04:41.342: I/DEBUG(27): pid: 295, tid: 295 >>> com.android.horse <<<
05-01 17:04:41.342: I/DEBUG(27): signal 11 (SIGSEGV), fault addr 00000008
05-01 17:04:41.342: I/DEBUG(27): r0 00000000 r1 beac7ae8 r2 4187033c r3 00000000
05-01 17:04:41.342: I/DEBUG(27): r4 beac7ae8 r5 4186be84 r6 beac7ae0 r7 40009ae8
05-01 17:04:41.342: I/DEBUG(27): r8 ad00f380 r9 0000bd00 10 4186be58 fp 00000000
05-01 17:04:41.342: I/DEBUG(27): ip 00000000 sp beac7a90 lr ad0544d3 pc ad034474 cpsr 40000030
05-01 17:04:41.400: I/DEBUG(27): #00 pc 00034474 /system/lib/libdvm.so
05-01 17:04:41.400: I/DEBUG(27): #01 pc 000544ce /system/lib/libdvm.so
05-01 17:04:41.400: I/DEBUG(27): #02 pc 00013f58 /system/lib/libdvm.so
05-01 17:04:41.411: I/DEBUG(27): #03 pc 00019888 /system/lib/libdvm.so
05-01 17:04:41.411: I/DEBUG(27): #04 pc 00018d5c /system/lib/libdvm.so
05-01 17:04:41.411: I/DEBUG(27): #05 pc 0004d6d0 /system/lib/libdvm.so
05-01 17:04:41.411: I/DEBUG(27): #06 pc 0004d702 /system/lib/libdvm.so
05-01 17:04:41.411: I/DEBUG(27): #07 pc 000404b8 /system/lib/libdvm.so
05-01 17:04:41.411: I/DEBUG(27): #08 pc 00041334 /system/lib/libdvm.so
05-01 17:04:41.420: I/DEBUG(27): #09 pc 00037e3a /system/lib/libdvm.so
05-01 17:04:41.420: I/DEBUG(27): #10 pc 00027a12 /system/lib/libdvm.so
05-01 17:04:41.420: I/DEBUG(27): #11 pc 00027c7e /system/lib/libandroid_runtime.so
05-01 17:04:41.420: I/DEBUG(27): #12 pc 00008cae /system/bin/app_process
05-01 17:04:41.420: I/DEBUG(27): #13 pc 0000c2c6 /system/lib/libc.so
05-01 17:04:41.420: I/DEBUG(27): #14 pc b00018aa /system/bin/linker
05-01 17:04:41.430: I/DEBUG(27): code around pc:
05-01 17:04:41.430: I/DEBUG(27): ad034464 bdf0b011 0004bbfc 00000354 1c03b510
05-01 17:04:41.430: I/DEBUG(27): ad034474 30106899 f7ff0849 bd10ff65 4d37b5f0
05-01 17:04:41.430: I/DEBUG(27): ad034484 9100b083 1c16447d d0012a00 60132300
05-01 17:04:41.430: I/DEBUG(27): code around lr:
05-01 17:04:41.430: I/DEBUG(27): ad0544c0 f86ef7ea 46c0bd10 6800b510 f7df1c0c
05-01 17:04:41.430: I/DEBUG(27): ad0544d0 6020ffcf 46c0bd10 1c0cb510 fa8cf7ec
05-01 17:04:41.430: I/DEBUG(27): ad0544e0 22002101 ffccf7df bd106020 1c03b510
05-01 17:04:41.430: I/DEBUG(27): stack:
05-01 17:04:41.430: I/DEBUG(27): beac7a50 0000bd00 [heap]
05-01 17:04:41.430: I/DEBUG(27): beac7a54 00000012
05-01 17:04:41.430: I/DEBUG(27): beac7a58 00000000
05-01 17:04:41.430: I/DEBUG(27): beac7a5c 4506848e /dev/ashmem/mspace/dalvik-heap/2 (deleted)
05-01 17:04:41.430: I/DEBUG(27): beac7a60 00000001
05-01 17:04:41.430: I/DEBUG(27): beac7a64 ad054403 /system/lib/libdvm.so
05-01 17:04:41.430: I/DEBUG(27): beac7a68 00000001
05-01 17:04:41.430: I/DEBUG(27): beac7a6c 0005c368 [heap]
05-01 17:04:41.430: I/DEBUG(27): beac7a70 00000000
05-01 17:04:41.430: I/DEBUG(27): beac7a74 00000001
05-01 17:04:41.430: I/DEBUG(27): beac7a78 000007ab
05-01 17:04:41.430: I/DEBUG(27): beac7a7c 00000001
05-01 17:04:41.440: I/DEBUG(27): beac7a80 afe0df40 /system/lib/libc.so
05-01 17:04:41.440: I/DEBUG(27): beac7a84 00000001
05-01 17:04:41.440: I/DEBUG(27): beac7a88 df002777
05-01 17:04:41.440: I/DEBUG(27): beac7a8c e3a070ad
05-01 17:04:41.440: I/DEBUG(27): #00 beac7a90 beac7ae8 [stack]
05-01 17:04:41.440: I/DEBUG(27): beac7a94 ad0544d3 /system/lib/libdvm.so
05-01 17:04:41.440: I/DEBUG(27): #01 beac7a98 41f7c228 /data/dalvik-cache/system@framework@core.jar@classes.dex
05-01 17:04:41.440: I/DEBUG(27): beac7a9c ad013f5c /system/lib/libdvm.so
05-01 17:04:41.790: D/Zygote(29): Process 295 terminated by signal (11)
05-01 17:04:41.790: I/WindowManager(51): WIN DEATH: Window{44df4c38 com.android.horse/com.android.horse.HorseEdgeActivity paused=false}
05-01 17:04:41.790: I/ActivityManager(51): Process com.android.horse (pid 295) has died.
有谁知道我的代码出了什么问题?
答案 0 :(得分:2)
我的代码也遇到了同样的问题,然后我打开了我的清单,发现有多个非必需的标签,无论是双重声明还是非封闭,在纠正它们之后我的应用程序现在正常工作。
这就是我之前看过的那种
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<intent-filter >
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
</intent-filter>
</activity>
<activity android:name=".SecondActivity"/>
<activity android:name=".ThirdActivity"/>
<activity android:name=".FourthActivity"/>
<activity android:name=".FifthActivity"/>
<activity android:name=".SixthActivity"/>
<activity android:name=".SeventhActivity"/>
</application>
并且在做了一些修正后现在看起来像这样,
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.project.mil"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="5"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
</activity>
<activity android:name=".SecondActivity"/>
<activity android:name=".ThirdActivity"/>
<activity android:name=".FourthActivity"/>
<activity android:name=".FifthActivity"/>
<activity android:name=".SixthActivity"/>
<activity android:name=".SeventhActivity"/>
</application>
</manifest>
只要存在未被捕获的线程异常,就意味着存在运行时错误,或者更准确地说是程序流中的错误。
如果这不起作用,请参阅 Uncaught handler: thread main exiting due to uncaught exception 其中还讨论了线程。