Android 的 Proguard 配置支持 v4 22.2.0
Proguard configuration for Android Support v4 22.2.0
从本地 Maven extras 存储库(在 SDK 中)更新 Gradle Android build 以使用 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.**
即可解决问题,但我想要一个 specific/elegant 的解决方案,而不是忽略 support.v4 包
上的所有问题
谁能告诉我应该添加哪些规则,以便 Proguard 正确处理这些 类/@interfaces?
根据 Android 团队的说法,为支持库 类 设置不警告是安全的。您可以通过以下方式执行此操作:
## Support library
-dontwarn android.support.**
唯一的解决办法就是你提到的,即-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.**
从本地 Maven extras 存储库(在 SDK 中)更新 Gradle Android build 以使用 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.**
即可解决问题,但我想要一个 specific/elegant 的解决方案,而不是忽略 support.v4 包
谁能告诉我应该添加哪些规则,以便 Proguard 正确处理这些 类/@interfaces?
根据 Android 团队的说法,为支持库 类 设置不警告是安全的。您可以通过以下方式执行此操作:
## Support library
-dontwarn android.support.**
唯一的解决办法就是你提到的,即-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.**