2014-02-05 86 views
5

我在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 

任何想法,爲什麼發生這種情況?

回答

1

我解決了這個問題。它是由一個配置問題在我的IntelliJ安裝引起的:

項目右鍵 - >打開模塊設置 - >構面選項 - >編譯器標籤:

  1. 確保Proguard的啓用
  2. 確保配置文件路徑應顯示:
    • 我們的項目中的proguard-project.txt文件
    • SDK中的proguard-android.txt。

在我來說,它只是顯示了從SDK中的一個,所以並沒有被考慮到,我正在給我的項目中文件的更改。

在此更改後,我可以使用Proguard文檔中顯示的Proguard選項並修復這些警告。

文件project.properties由IntelliJ自動生成,不應該手動修改。即使此文件顯示它正在使用這兩個文件進行配置,它也不一定是真實的,請檢查「設置」對話框。

相關問題