2015-06-04 81 views
19

在更新Gradle Android版本的依賴關係後,使用本地Maven extras版本庫(SDK內)的com.android.support:support-v4:22.2.0,Proguard開始拋出這些問題。Android版Proguard配置支持v4 22.2.0

Warning: android.support.v4.app.DialogFragment: can't find referenced class android.support.v4.app.DialogFragment$DialogStyle 
Warning: android.support.v4.app.FragmentTransaction: can't find referenced class android.support.v4.app.FragmentTransaction$Transit 
Warning: android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$ResolvedLayoutDirectionMode 
Warning: android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$LayoutDirectionMode 
Warning: android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$LayerType 
Warning: android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$AccessibilityLiveRegion 
Warning: android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$ImportantForAccessibility 
Warning: android.support.v4.view.ViewCompat: can't find referenced class android.support.v4.view.ViewCompat$OverScroll 
Warning: android.support.v4.widget.DrawerLayout: can't find referenced class android.support.v4.widget.DrawerLayout$EdgeGravity 
Warning: android.support.v4.widget.DrawerLayout: can't find referenced class android.support.v4.widget.DrawerLayout$LockMode 
Warning: android.support.v4.widget.DrawerLayout: can't find referenced class android.support.v4.widget.DrawerLayout$State 
Warning: there were 11 unresolved references to classes or interfaces. 
     You may need to add missing library jars or update their versions. 
     If your code works fine without the missing classes, you can suppress 
     the warnings with '-dontwarn' options. 
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass) 

簡單地增加-dontwarn android.support.v4.**解決了這個問題,但我想一個更具體的/優雅的解決方案,比無視support.v4包中的所有問題

誰能告訴應該加什麼規則,所以這些類/ @接口是否被Proguard正確處理?

+1

我有同樣的問題。 – sanath01

+1

即使我面對這個問題很多次, ,但唯一的解決方案,我可以使用'-dontwarn' –

回答

12

唯一的解決辦法就是你所提到的情況,即-dontwarn android.support.v4.**。這實際上取自<path-to-android-sdk>/tools/proguard/proguard-android.txt,它說:

# The support library contains references to newer platform versions. 
# Don't warn about those in case this app is linking against an older 
# platform version. We know about them, and they are safe. 
-dontwarn android.support.** 
3

根據Android團隊設置不要警告支持庫類是安全的。您可以通過這樣做:

## Support library 
-dontwarn android.support.** 
+1

這並沒有多大幫助,因爲dontwarn不解決問題,它隱藏它... –

+0

什麼問題?你的應用崩潰了嗎? – Splaktar

+0

不,但構建是,那讓我擔心 –