在Android应用上使用Proguard时出现以下错误。
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$2: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$3: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$4: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$5: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$6: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$7: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$8: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$9: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanMap$Entry: can't find superclass or interface org.apache.commons.collections.keyvalue.AbstractMapEntry
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanPredicate: can't find superclass or interface org.apache.commons.collections.Predicate
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanPropertyValueChangeClosure: can't find superclass or interface org.apache.commons.collections.Closure
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanPropertyValueEqualsPredicate: can't find superclass or interface org.apache.commons.collections.Predicate
ProGuard: [sand] Warning: org.apache.commons.beanutils.BeanToPropertyValueTransformer: can't find superclass or interface org.apache.commons.collections.Transformer
ProGuard: [sand] Warning: org.apache.commons.beanutils.MappedPropertyDescriptor: can't find superclass or interface java.beans.PropertyDescriptor
ProGuard: [sand] Warning: org.apache.commons.logging.impl.ServletContextCleaner: can't find superclass or interface javax.servlet.ServletContextListener
ProGuard: [sand] Warning: roboguice.activity.RoboMapActivity: can't find superclass or interface com.google.android.maps.MapActivity
ProGuard: [sand] Warning: roboguice.test.shadow.ShadowFragmentActivity: can't find superclass or interface com.xtremelabs.robolectric.shadows.ShadowActivity
ProGuard: [sand] Warning: library class org.apache.http.auth.AuthenticationException extends or implements program class org.apache.http.ProtocolException
ProGuard: [sand] Warning: library class org.apache.http.auth.MalformedChallengeException extends or implements program class org.apache.http.ProtocolException
ProGuard: [sand] Warning: library class org.apache.http.auth.params.AuthParamBean extends or implements program class org.apache.http.params.HttpAbstractParamBean
... keeps going till 743 errors (warnings)
我已经尝试了几种方法来防止这种情况发生(-dontskipnonpubliclibraryclassmembers,-keep,-dontwarn,-ignorewarnings)但没有成功。也许我没有正确使用这些选项。我正在使用IntelliJ并针对android-19(Android 4.4.2)。
该应用程序使用一些第三方库构建:一些包含在libs文件夹中,另一些则包含在Maven pom.xml中。我怀疑通过pom.xml包含的库没有包含在-libraryjars选项中。
我的project.properties看起来像这样:
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
proguard.config=${sdk.dir}/tools/proguard/proguard-android-optimize.txt:proguard-project.txt
# Project target.
target=android-19
我的proguard-project.txt看起来像这样:
-dontskipnonpubliclibraryclassmembers
# Libraries
-dontwarn org.apache.**
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
# WebView with JS: specify the fully qualified class name to the JavaScript interface class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public *;
}
# Database model
-keep class com.mycompany.model.db.**
-keepclassmembers class com.mycompany.model.db.** { *; }
# Project target.
target=android-19
为什么会发生这种情况?
答案 0 :(得分:3)
我解决了这个问题。这是由我的IntelliJ安装中的配置问题引起的:
项目右键单击 - >打开模块设置 - >构面选项 - >编译器选项卡:
在我的情况下,它只显示SDK中的那个,所以我在项目中对文件所做的更改没有被考虑在内。
在此更改之后,我可以使用Proguard文档中显示的Proguard选项并修复这些警告。
文件project.properties由IntelliJ自动生成,不应手动修改。即使此文件显示正在使用这两个文件进行配置,也不一定如此,请查看“设置”对话框。