Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could not find class 'com.lowagie.text.pdf.PdfReader'

 
Nacer Heithem
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created an android application which sign a pdf file using iText.
The project runs perfectly fine on API levels, but, I'm getting some problems on emulators.
When I load up the application on an emulator, I get this problem:

02-21 20:51:52.368: E/dalvikvm(410): Could not find class 'com.lowagie.text.pdf.PdfReader', referenced from method com.exampl.exemp.Sign_pdf.signPdf
02-21 20:51:52.368: W/dalvikvm(410): VFY: unable to resolve new-instance 26 (Lcom/lowagie/text/pdf/PdfReader;) in Lcom/exampl/exemp/Sign_pdf;
02-21 20:51:52.378: D/dalvikvm(410): VFY: replacing opcode 0x22 at 0x004a
02-21 20:51:52.398: D/dalvikvm(410): VFY: dead code 0x004c-0095 in Lcom/exampl/exemp/Sign_pdf;.signPdf ()Z
02-21 20:51:57.187: I/dalvikvm(410): Total arena pages for JIT: 11
02-21 20:51:57.227: I/dalvikvm(410): Total arena pages for JIT: 12
02-21 20:51:57.487: D/AndroidRuntime(410): Shutting down VM
02-21 20:51:57.497: W/dalvikvm(410): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-21 20:51:57.517: E/AndroidRuntime(410): FATAL EXCEPTION: main
02-21 20:51:57.517: E/AndroidRuntime(410): java.lang.NoClassDefFoundError: com.lowagie.text.pdf.PdfReader
02-21 20:51:57.517: E/AndroidRuntime(410): at com.exampl.exemp.Sign_pdf.signPdf(Sign_pdf.java:47)
02-21 20:51:57.517: E/AndroidRuntime(410): at com.exampl.exemp.MainActivity.editText(MainActivity.java:114)
02-21 20:51:57.517: E/AndroidRuntime(410): at com.exampl.exemp.MainActivity.onCreate(MainActivity.java:36)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.os.Handler.dispatchMessage(Handler.java:99)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.os.Looper.loop(Looper.java:123)
02-21 20:51:57.517: E/AndroidRuntime(410): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-21 20:51:57.517: E/AndroidRuntime(410): at java.lang.reflect.Method.invokeNative(Native Method)
02-21 20:51:57.517: E/AndroidRuntime(410): at java.lang.reflect.Method.invoke(Method.java:507)
02-21 20:51:57.517: E/AndroidRuntime(410): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-21 20:51:57.517: E/AndroidRuntime(410): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-21 20:51:57.517: E/AndroidRuntime(410): at dalvik.system.NativeStart.main(Native Method)
02-21 20:56:57.660: I/Process(410): Sending signal. PID: 410 SIG: 9

The problem maybe is comming up with the iText jar so what is the compatible version with android. Any help greatly appreciated...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a iTextG designed for Android and Google App Engine. I see the benefits for Google App Engine on that page, but not for Android. It sounds like the change is that it uses a different underlying library (Bouncy Castle vs Spongy Castle)

I also see people have used regular iText on Android. They tested with writing files though - not reading them.

If you don't make progress with iText, you might consider using PDF Box.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find it amazing that iText works at all on Android - it has a lot of AWT dependencies that would not work on Android. I guess it's possible to use just some subset of iText that by chance do not depend on AWT. PDFBox would have the same problem.

The error is strange though. How does your build supply the iText library - is it in the "libs" directory? Is maybe obfuscation used somewhere?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic