ProGuard强制使用“-dontwarn”导致Android App行为不正确

时间:2012-11-10 18:35:06

标签: android proguard itextpdf

我有一个应用程序,我想用progaurd构建我在这个应用程序中使用kso​​ap和itext jar现在问题是在发布模式下构建应用程序(签名apk)我收到错误(请参阅下面的错误日志)我之前尝试使用-dontwarn解决此错误,但在安装apk后使用此应用程序停止表现就像用于我认为从jar文件引用的几个类行为不正常或任何可能的原因。这有什么有效的解决方案吗?任何帮助将不胜感激。谢谢!

[2012-11-10 23:52:17 - Nestle-SHSH] Proguard returned with error code 1. See console
[2012-11-10 23:52:17 - Nestle-SHSH] Note: there were 4 duplicate class definitions.
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find superclass or interface java.awt.Graphics2D
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D$FakeComponent: can't find superclass or interface java.awt.Component
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D$HyperLinkKey: can't find superclass or interface java.awt.RenderingHints$Key
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfPrinterGraphics2D: can't find superclass or interface java.awt.print.PrinterGraphics
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.geom.PolylineShape: can't find superclass or interface java.awt.Shape
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.geom.PolylineShapeIterator: can't find superclass or interface java.awt.geom.PathIterator
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: library class android.content.res.XmlResourceParser extends or implements program class org.xmlpull.v1.XmlPullParser
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.AsianFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.DefaultFontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.FontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.FontMapper: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.BufferedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.BufferedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.BufferedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.RenderingHints
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.RenderingHints
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Graphics2D
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Graphics2D
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.BasicStroke
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.BasicStroke
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.RenderingHints
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.RenderingHints
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.AffineTransform
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.AffineTransform
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Color
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Color
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Area
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Rectangle2D$Float
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Rectangle2D$Float
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Area
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.BufferedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.BufferedImageOp
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.BufferedImageOp
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.RenderedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.RenderedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.RenderedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.ColorModel
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.ColorModel
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.RenderedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.RenderedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.BufferedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.RenderedImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.image.renderable.RenderableImage
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Color
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.AffineTransform
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.AffineTransform
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.AffineTransform
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.AffineTransform
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Color
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Color
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Rectangle2D
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.Font
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Rectangle2D
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Line2D$Double
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.geom.Line2D$Double
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced method 'java.awt.FontMetrics getFontMetrics()' in class com.itextpdf.awt.PdfGraphics2D
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: com.itextpdf.awt.PdfGraphics2D: can't find referenced class java.awt.FontMetrics
[2012-11-10 23:52:17 - Nestle-SHSH]          You must avoid such dependencies, since the program classes will
[2012-11-10 23:52:17 - Nestle-SHSH]          be processed, while the library classes will remain unchanged.
[2012-11-10 23:52:17 - Nestle-SHSH] Warning: there were 1 unresolved references to program class members.
[2012-11-10 23:52:17 - Nestle-SHSH]          Your input classes appear to be inconsistent.
[2012-11-10 23:52:17 - Nestle-SHSH]          You may need to recompile them and try again.
[2012-11-10 23:52:17 - Nestle-SHSH]          Alternatively, you may have to specify the option 
[2012-11-10 23:52:17 - Nestle-SHSH]          '-dontskipnonpubliclibraryclassmembers'.
[2012-11-10 23:52:17 - Nestle-SHSH] java.io.IOException: Please correct the above warnings first.
[2012-11-10 23:52:17 - Nestle-SHSH]     at proguard.Initializer.execute(Initializer.java:321)
[2012-11-10 23:52:17 - Nestle-SHSH]     at proguard.ProGuard.initialize(ProGuard.java:211)
[2012-11-10 23:52:17 - Nestle-SHSH]     at proguard.ProGuard.execute(ProGuard.java:86)
[2012-11-10 23:52:17 - Nestle-SHSH]     at proguard.ProGuard.main(ProGuard.java:492)

这是我的proguard.cfg文件: -

-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-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 *;
}

2 个答案:

答案 0 :(得分:0)

我在应用程序崩溃的代码中做了一些调整,但我认为这只是我的情况下的解决方案,因为我有另一种方法。是关于使用novocation库获取位置,我用其他一些代码替换。但我仍然没有得到任何答案的主要问题是,当使用proguard构建应用程序时,为什么这些库会停止正常行为。我在我的应用程序中使用了jar文件的源代码,发现由于某些匿名代码的原因,某些类没有编译,这最初是在使用proguard构建时出现警告的原因。我只是删除了显示编译时错误的类(这些只是少数而且对代码的功能没有影响)这可以等同于proguard.cfg文件中的-dontwarn。所以我认为它仍然需要一些深入的研究。感谢@pst提供宝贵的建议。

答案 1 :(得分:0)

您可以添加

-dontwarn com.itextpdf.** 

到您的proguard文件 或迁移到

com.itextpdf:itextg:**