收到太多 Proguard 警告

Posted

技术标签:

【中文标题】收到太多 Proguard 警告【英文标题】:Getting too many Proguard warnings 【发布时间】:2011-10-07 18:57:11 【问题描述】:

我试图混淆我打包到 SINGEL jar 中的 java 应用程序。该应用程序使用 SWT gui 库等。我已经通过 -libraryjars 在 Proguard 配置文件中正式列出了它们,但我仍然收到太多相同类型的警告,即: "警告:库类 org.eclipse.swt.accessibility.Accessible$10 扩展或实现程序类 org.eclipse.swt.internal.ole.win32.COMObject"

这里做错了什么??

这是我的 Proguard 配置的样子:

-injars 'D:\Tasks\Deployment\NEW - 30.06.2011\proguard4.6\lib\fevflex.jar'
-outjars 'D:\Tasks\Deployment\NEW - 30.06.2011\proguard4.6\lib\fevflex_out.jar'

-libraryjars 'C:\Program Files\Java\jre6\lib\rt.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\resources.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\jsse.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\jce.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\charsets.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\ext\dnsns.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\ext\localedata.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\ext\sunjce_provider.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\ext\sunmscapi.jar'
-libraryjars 'C:\Program Files\Java\jre6\lib\ext\sunpkcs11.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\commons-collections-3.2.1.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\commons-io-2.0.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\mysql-connector-java-5.1.7-bin.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\org.eclipse.core.commands_3.4.0.I20080509-2000.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\org.eclipse.equinox.common_3.4.0.v20080421-2006.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\org.eclipse.jface_3.4.2.M20090107-0800.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\org.eclipse.nebula.widgets.grid-1.0.0-SNAPSHOT.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\org.swtchart_0.6.0.v20090801.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\swt.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\swt_64bit.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\swtgraphics2d.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\testng.jar'
-libraryjars 'D:\eclipse\workspace\main\Code\demo\lib\xom-1.2.6.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\c3p0-0.9.1.1.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\jboss-common-jdbc-wrapper.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\log4j-1.2.6.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\org.eclipse.swt.win32.win32.x86_3.3.0.v3346.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\xml-apis.jar'
-libraryjars 'D:\eclipse\eclipse\plugins\org.eclipse.osgi_3.6.1.R36x_v20100806.jar'
-libraryjars 'D:\eclipse\eclipse\plugins\org.eclipse.osgi.services_3.2.100.v20100503.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\eclipseAdaptor.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\org.eclipse.osgi_3.3.0.v20070530.jar'
-libraryjars 'D:\eclipse\eclipse\morelibs\xerces-2.2.1.jar'
-libraryjars 'D:\eclipse\eclipse\plugins\org.apache.commons.logging_1.0.4.v201005080501.jar'

-dontskipnonpubliclibraryclassmembers
-dontshrink
-dontoptimize
-dontusemixedcaseclassnames
-adaptresourcefilenames **.properties
-adaptresourcefilecontents **.properties,META-INF/MANIFEST.MF
-dontpreverify
-dontnote
-ignorewarnings
-printconfiguration 'D:\Tasks\Deployment\NEW - 30.06.2011\proguard4.6\lib\FLEX.pro'


-keep public class main.FEVFlex 
    public static void main(java.lang.String[]);


-keep class nu.** 
    <fields>;
    <methods>;


-keep class org.** 
    <fields>;
    <methods>;


-keep class com.** 
    <fields>;
    <methods>;


# Also keep - Enumerations. Keep the special static methods that are required in
# enumeration classes.
-keepclassmembers enum  * 
    public static **[] values();
    public static ** valueOf(java.lang.String);


# Keep names - Native method names. Keep all native class/method names.
-keepclasseswithmembers,allowshrinking class * 
    native <methods>;

【问题讨论】:

【参考方案1】:

ProGuard manual > Troubleshooting > Warning: library class ... depends on program class ...

在这种情况下,org.eclipse.swt.internal.ole.win32.COMObject 似乎在您的输入 jar fevflex.jar 中。您应该将其删除,或者至少将其作为库 jar 的一部分。

【讨论】:

【参考方案2】:

我注意到您在库中同时包含 swt.jar 和 swt_64bit.jar,而一次只能使用其中一个。也许这是您收到大量警告的原因之一。

【讨论】:

以上是关于收到太多 Proguard 警告的主要内容,如果未能解决你的问题,请参考以下文章

Gradle 3.0.0 的 Proguard 问题

Proguard给了我很多警告并且失败了

如何抑制来自 ProGuard 的“也许这是程序方法”警告

Proguard 警告:找不到引用的类 scala。*

Proguard和mixpanel问题

ProGuard 警告不允许我的应用编译发布