Hola amigos antes que nada gracias a los que lean y responda mi pregunta. Estoy implementado una APP Android nativa en la requiero generar un documento PDF, estoy tratando de hacerlo con la librería compileOnly 'com.itextpdf:itextg:5.5.10'
pero me esta generando un error al ejecutar la instancia de documento.
Este es el error que me esta presentando:
2019-07-15 11:47:19.948 26039-26039/com.example.boletas E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.boletas, PID: 26039
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/itextpdf/text/Document;
at com.example.boletas.PreloaderActivity.onCreate(PreloaderActivity.java:90)
at android.app.Activity.performCreate(Activity.java:6977)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6816)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1565)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1453)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.itextpdf.text.Document" on path: DexPathList[[zip file "/data/app/com.example.boletas-2/base.apk", zip file "/data/app/com.example.boletas-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.boletas-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.boletas-2/lib/arm, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.example.boletas.PreloaderActivity.onCreate(PreloaderActivity.java:90)
at android.app.Activity.performCreate(Activity.java:6977)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1126)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2946)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3064)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1659)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6816)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1565)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1453)
Les dejo referencia del código que estoy aplicando:
String filename = "test.pdf";
try {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(folder + filename));
document.open();
document.close();
} catch (Exception e) {
e.printStackTrace();
}
Gracias si en la respuesta me pudiera ayudar con referencia también a como configurar el ancho del PDF les agradecería.