如果我使用itext库jar,则会出现Proguard错误 [英] Proguard error if i use itext Library jar

查看:89
本文介绍了如果我使用itext库jar,则会出现Proguard错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Proguard无法与iText库一起使用.错误与org.spongycastle.** org.bouncycastle.*com.itext.pdf.**有关,我尝试对这些软件包使用keep失败.

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.

我的proguard配置文件是这样的:

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

错误日志

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.

推荐答案

尝试以下两行:

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

您的logcat已经在说:

Your logcat is already saying:

如果您的代码在没有缺少类的情况下运行良好,则可以使用'-dontwarn'选项禁止显示警告.

If your code works fine without the missing classes, you can suppress the warnings with '-dontwarn' options.

这篇关于如果我使用itext库jar,则会出现Proguard错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆