猿问

由 java.lang.NoSuchMethodException <init>

Caused by java.lang.NoSuchMethodException: <init> [class com.itextpdf.text.Image]

       at java.lang.Class.getConstructor0(Class.java:2320)

       at java.lang.Class.getDeclaredConstructor(Class.java:2166)

       at com.itextpdf.text.Image.getInstance(Unknown Source:16)

       at com.itextpdf.text.pdf.PdfPCell.(Unknown Source:124)

       at com.itextpdf.text.pdf.PdfPTable.addCell(Unknown Source:17)

       at com.itextpdf.text.pdf.ColumnText.addElement(Unknown Source:109)

       at com.itextpdf.text.pdf.PdfPCell.addElement(Unknown Source:63)

       at com.clystnet.wcr.wcrinternal.activitys.RaamsFormViewActivity$creatingPdf.doInBackground(Unknown Source:590)

       at com.clystnet.wcr.wcrinternal.activitys.RaamsFormViewActivity$creatingPdf.doInBackground(Unknown Source:2)

       at android.os.AsyncTask$2.call(AsyncTask.java:333)

       at java.util.concurrent.FutureTask.run(FutureTask.java:266)

Caused by com.itextpdf.text.ExceptionConverter: <init> [class com.itextpdf.text.Image]


当我在 crashlytics 中设置图像时,应用程序在发布版本中也崩溃了,它在任何行上都没有显示错误。请帮帮我。


    implementation 'com.itextpdf:itextpdf:5.5.13'

我的用于从可绘制图像添加图像的代码。


 Drawable d = getResources().getDrawable(R.drawable.wcr_logo);

                BitmapDrawable bitDw = ((BitmapDrawable) d);

                Bitmap bmp = bitDw.getBitmap();

                Image logo = null;

                if (bmp != null) {

                    ByteArrayOutputStream stream = new ByteArrayOutputStream();

                    bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);

                    if (stream != null) {

                        if (stream.size() > 0) {

                            Log.d("zcusfs","reached here2");

                            logo = Image.getInstance(stream.toByteArray(),true);

                            Log.d("zcusfs","reached here2c");

                            logo.scaleAbsolute(40, 40);

                            logo.setBorder(Image.NO_BORDER);

                        }

                    }

                }


      

繁花如伊
浏览 175回答 2
2回答

烙印99

将以下文本添加到您的 ProGuard 文件中# proguard configuration for iText-keep class org.spongycastle.** { *; }-dontwarn org.spongycastle.**-keep class com.itextpdf.** { *; }-keep class javax.xml.crypto.dsig.** { *; }-dontwarn javax.xml.crypto.dsig.**-keep class org.apache.jcp.xml.dsig.internal.dom.** { *; }-dontwarn org.apache.jcp.xml.dsig.internal.dom.**-keep class javax.xml.crypto.dom.** { *; }-dontwarn javax.xml.crypto.dom.**-keep class org.apache.xml.security.utils.** { *; }-dontwarn org.apache.xml.security.utils.**-keep class javax.xml.crypto.XMLStructure-dontwarn javax.xml.crypto.XMLStructure

慕姐8265434

就我而言,这是因为我启用了“minifyEnabled true”的 Progaurd。只需将其更改为“minifyEnabled false”并删除“shrinkResources true”。在 build.gradle (应用程序级别)buildTypes {&nbsp; &nbsp; &nbsp; &nbsp; release {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minifyEnabled false&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; debuggable false&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; debug {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; debuggable true&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; minifyEnabled false&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; }
随时随地看视频慕课网APP

相关分类

Java
我要回答