用“ProGuard”强制-dontwarn“;导致Android应用程序行为不正确

用“ProGuard”强制-dontwarn“;导致Android应用程序行为不正确,android,proguard,itextpdf,Android,Proguard,Itextpdf,我有一个应用程序,我想用progaurd构建我在这个应用程序中使用ksoap和itext jars现在的问题是,在发布模式下构建应用程序时(签名apk),我遇到了错误(请参阅下面的错误日志)我之前尝试过使用-dontwarn来解决这个错误,但是在我安装apk后,应用程序的行为就不再像以前那样了,我认为从jar文件中引用的类很少有不正常的行为,或者可能是什么原因。有什么有效的解决办法吗?任何帮助都将不胜感激。谢谢 [2012-11-10 23:52:17 - Nestle-SHSH] Progua

我有一个应用程序,我想用progaurd构建我在这个应用程序中使用ksoap和itext jars现在的问题是,在发布模式下构建应用程序时(签名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 *;
}
-优化过程5
-dontusemixedcaseclassnames
-DontskipnonPublicLibraryClass
-不要翻转
-冗长的
-优化!代码/简化/算术,!字段/*,!类/合并/*
-keep public class*扩展android.app.Activity
-keep public class*扩展android.app.Application
-keep public class*扩展了android.app.Service
-keep public class*扩展了android.content.BroadcastReceiver
-keep public class*扩展了android.content.ContentProvider
-keep public class*扩展了android.app.backup.BackupAgentHelper
-keep public class*扩展了android.preference.preference
-保持公共类com.android.vending.licensing.ILicensingService
-KeepClassSwithMemberNames类*{
出生地的
}
-keepclassswithmembers类*{
public(android.content.Context、android.util.AttributeSet);
}
-keepclassswithmembers类*{
public(android.content.Context,android.util.AttributeSet,int);
}
-keepclassmembers类*扩展了android.app.Activity{
public void*(android.view.view);
}
-keepclassmembers枚举*{
公共静态**[]值();
公共静态**valueOf(java.lang.String);
}
-keep class*实现android.os.Parcelable{
公开静态最终android.os.Parcelable$Creator*;
}

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

您只需添加

-dontwarn com.itextpdf.** 
到您的proguard文件 或者迁移到

com.itextpdf:itextg:**

可能是,但不是在这种情况下。应用程序运行不正常的部分itext不起作用。itext只是使用i文本的一个小部分。那么ksoap呢?那么我的建议是尝试使用一个只与ksoap有问题的构建来删除所有额外的(itext)工件。解决这个问题的“修复”方法是使用
-dontwarn
,正如我所发现的,这可能会使它在部署时“无法工作”。ProGuard正在做一件明智的事情:它发出警告并拒绝继续,除非是被迫的。修复警告/问题的来源。可以说它是/是ProGuard的唯一方法是在没有[停止]警告的情况下成功运行。由于您已决定不修复警告,因此我已更新标题,不再关注发出的非常有效的警告。YMMV。(最好花点时间解释一下“应用程序不再像过去那样运行”是什么意思。)谢谢你的努力,但我已经找到了解决这个问题的方法。