Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard error if i use itext Library jar

Proguard won't work with iText library. the errors are related to org.spongycastle.** org.bouncycastle.* and com.itext.pdf.** I have tried to use keep on these packages without success.

My proguard config file is this:

-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

The error log

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.
like image 794
AndreaF Avatar asked Apr 14 '14 11:04

AndreaF


1 Answers

This works fine for 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
like image 192
Tharindu Bandara Avatar answered Oct 13 '22 18:10

Tharindu Bandara