web-dev-qa-db-ja.com

Androidサポートv422.2.0のProguard構成

Gradleの依存関係を更新した後AndroidビルドしてローカルのMavenエクストラリポジトリ(SDK内)からcom.Android.support:support-v4:22.2.0を使用する)、Proguardはこれらの問題をスローし始めました。

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によって正しく処理されるように、追加する必要があるルールを誰かが教えてもらえますか?

21
Marek Sebera

唯一の解決策は、あなたが言及したこと、つまり-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.**
16
Sufian

Androidチームに従って、サポートライブラリクラスに対して警告しないように設定しても安全です。これは次の方法で実行できます。

## Support library
-dontwarn Android.support.**
4
Splaktar