6

我试图混淆我的 android 应用程序但是我收到以下错误:

[2012-04-15 19:55:51 - TmtAndroid] Proguard returned with error code 1. See console
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ClassPathElement: can't find referenced method 'org.apache.tools.ant.Project getProject()' in class proguard.ant.ClassPathElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ClassPathElement: can't find referenced method 'boolean isReference()' in class proguard.ant.ClassPathElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ClassPathElement: can't find referenced method 'java.lang.Object getCheckedRef(java.lang.Class,java.lang.String)' in class proguard.ant.ClassPathElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ClassPathElement: can't find referenced method 'java.lang.String[] list()' in class proguard.ant.ClassPathElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ClassPathElement: can't find referenced method 'void setLocation(java.io.File)' in class proguard.ant.ClassPathElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ClassSpecificationElement: can't find referenced method 'boolean isReference()' in class proguard.ant.ClassSpecificationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ClassSpecificationElement: can't find referenced method 'java.lang.Object getCheckedRef(java.lang.Class,java.lang.String)' in class proguard.ant.ClassSpecificationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ConfigurationElement: can't find referenced method 'boolean isReference()' in class proguard.ant.ConfigurationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ConfigurationElement: can't find referenced method 'java.lang.Object getCheckedRef(java.lang.Class,java.lang.String)' in class proguard.ant.ConfigurationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ConfigurationTask: can't find referenced method 'org.apache.tools.ant.Project getProject()' in class proguard.ant.ConfigurationTask
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.FilterElement: can't find referenced method 'boolean isReference()' in class proguard.ant.FilterElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.FilterElement: can't find referenced method 'java.lang.Object getCheckedRef(java.lang.Class,java.lang.String)' in class proguard.ant.FilterElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.KeepSpecificationElement: can't find referenced method 'boolean isReference()' in class proguard.ant.KeepSpecificationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.KeepSpecificationElement: can't find referenced method 'java.lang.Object getCheckedRef(java.lang.Class,java.lang.String)' in class proguard.ant.KeepSpecificationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.MemberSpecificationElement: can't find referenced method 'boolean isReference()' in class proguard.ant.MemberSpecificationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.MemberSpecificationElement: can't find referenced method 'java.lang.Object getCheckedRef(java.lang.Class,java.lang.String)' in class proguard.ant.MemberSpecificationElement
[2012-04-15 19:55:51 - TmtAndroid] Warning: proguard.ant.ProGuardTask: can't find referenced method 'org.apache.tools.ant.Project getProject()' in class proguard.ant.ProGuardTask
[2012-04-15 19:55:51 - TmtAndroid]       You should check if you need to specify additional program jars.
[2012-04-15 19:55:51 - TmtAndroid] Warning: there were 17 unresolved references to program class members.
[2012-04-15 19:55:51 - TmtAndroid]          Your input classes appear to be inconsistent.
[2012-04-15 19:55:51 - TmtAndroid]          You may need to recompile them and try again.
[2012-04-15 19:55:51 - TmtAndroid]          Alternatively, you may have to specify the option 
[2012-04-15 19:55:51 - TmtAndroid]          '-dontskipnonpubliclibraryclassmembers'.
[2012-04-15 19:55:51 - TmtAndroid] java.io.IOException: Please correct the above warnings first.
[2012-04-15 19:55:51 - TmtAndroid]  at proguard.Initializer.execute(Initializer.java:321)
[2012-04-15 19:55:51 - TmtAndroid]  at proguard.ProGuard.initialize(ProGuard.java:211)
[2012-04-15 19:55:51 - TmtAndroid]  at proguard.ProGuard.execute(ProGuard.java:86)
[2012-04-15 19:55:51 - TmtAndroid]  at proguard.ProGuard.main(ProGuard.java:492)

当我添加

-dontwarn proguard.ant.**

到proguard.cfg,apk被导出,但在手机上安装后,它崩溃了,所以这不是这种情况下的解决方案......

我应该怎么做才能解决这些警告?这是我第一次与proguard互动...

谢谢

4

1 回答 1

1

我在使用Proguard时的一般方法是从一个非常小的.pro文件开始,所有内容都打开,然后开始关闭各种混淆/优化/收缩选项,直到生成的 jar 正确运行。

所以我建议浏览Proguard 示例页面-keep并尝试dontXXX他们建议的各种选项。

此外,您的应用程序(或 Android 框架)是否使用本机方法序列化反射回调方法注释等...?示例文档提供了您需要传递给Proguard的设置,以确保 Proguard 的字节码操作不会破坏这些功能。

例如,我对 Android 平台不是很熟悉,但我相信它使用某种类型的 XML 框架,告诉它如何加载/使用您定义的 Java 类。如果是这种情况,并且您让 Proguard 混淆了类或包名称,那么 XML 框架将无法再找到这些类。

于 2012-04-15T20:25:06.487 回答