Join FlipAndroid.COM Telegram Group: https://t.me/joinchat/F_aqThGkhwcLzmI49vKAiw


Proguard error si uso itext Library jar

Proguard no funcionará con la biblioteca iText. Los errores están relacionados con org.spongycastle.** org.bouncycastle.* Y com.itext.pdf.** He intentado usar mantener estos paquetes sin éxito.

Mi archivo de configuración proguard es el siguiente:

 -optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/* -optimizationpasses 5 -allowaccessmodification -dontpreverify -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -verbose -keepattributes *Annotation* -keep public class com.google.vending.licensing.ILicensingService -keep public class com.android.vending.licensing.ILicensingService # For native methods, see http://proguard.sourceforge.net/manual/examples.html#native -keepclasseswithmembernames class * { native <methods>; } -keepclassmembers public class * extends android.view.View { void set*(***); *** get*(); } -keepclassmembers class * extends android.app.Activity { public void *(android.view.View); } -keepclassmembers enum * { public static **[] values(); public static ** valueOf(java.lang.String); } -keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; } -keepclassmembers class * implements java.io.Serializable { static final long serialVersionUID; private static final java.io.ObjectStreamField[] serialPersistentFields; private void writeObject(java.io.ObjectOutputStream); private void readObject(java.io.ObjectInputStream); java.lang.Object writeReplace(); java.lang.Object readResolve(); } -keepclassmembers class **.R$* { public static <fields>; } -dontwarn android.support.** -dontwarn javax.activation.** -dontwarn org.apache.** -dontwarn org.bouncycastle.** -dontwarn sun.misc.Unsafe -dontwarn com.google.** -dontwarn com.esotericsoftware.** -dontwarn javax.naming.** -libraryjars <java.home>/lib/rt.jar -keepattributes *Annotation* -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class com.android.vending.licensing.ILicensingService -keep class com.google.** -keep class * extends com.google.api.client.json.GenericJson { *; } -keep class javax.** {*;} -keep class java.lang.reflect.** -keep class com.sun.** {*;} -keep class myjava.** {*;} -keep class org.apache.** -keep class org.bouncycastle.** -keep public class Mail {*;} -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep class org.spongycastle.** -keep class com.itextpdf.text.pdf.** {*;} -keep class com.esotericsoftware.** -dontshrink 

El registro de errores

 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD160$Digest Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD256$Digest Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.GOST3411$Digest Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.MD2 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.MD5 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA1 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA224 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA256 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA384 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.SHA512 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD128 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD160 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.RIPEMD256 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.BouncyCastleDigest: can't find referenced class org.spongycastle.jcajce.provider.digest.GOST3411 Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1Sequence Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1InputStream Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1TaggedObject Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo: can't find referenced class org.spongycastle.asn1.ASN1Primitive Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1Sequence Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1Set Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1String Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateInfo$X500Name: can't find referenced class org.spongycastle.asn1.ASN1ObjectIdentifier Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateUtil: can't find referenced class org.spongycastle.asn1.x509.Extension Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.CertificateUtil: can't find referenced class org.spongycastle.asn1.ASN1ObjectIdentifier Error:ProGuard: [MyApp] Warning: com.itextpdf.text.pdf.security.TSAInfoBouncyCastle: can't find referenced class org.spongycastle.tsp.TimeStampTokenInfo Error:ProGuard: [MyApp] Warning: there were 667 unresolved references to classes or interfaces. Error:ProGuard: [MyApp] You may need to add missing library jars or update their versions. Error:ProGuard: [MyApp] If your code works fine without the missing classes, you can suppress Error:ProGuard: [MyApp] the warnings with '-dontwarn' options. 

3 Solutions collect form web for “Proguard error si uso itext Library jar”

Intente con estas dos líneas:

 -keep class org.spongycastle.** { *; } -dontwarn org.spongycastle.** 

Su logcat ya está diciendo:

Si su código funciona bien sin las clases que faltan, puede suprimir las advertencias con las opciones '-dontwarn'.

Esto funciona bien para itextg-5.5.10

 # 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 

Utilicé la imagen para agregar en la tabla y conseguí el error como NoSuchMethodFound:

He añadido las siguientes líneas en proguard, su trabajo bien ahora.

 -keep class org.spongycastle.** { *; } -dontwarn org.spongycastle.** -keep class com.itextpdf.text.** { *; } -dontwarn com.itextpdf.text.** 

Gracias.

FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.