21

After updating dependencies on Gradle Android build to use com.android.support:support-v4:22.2.0 from local Maven extras repository (within SDK), Proguard started throwing these problems.

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) 

Simply adding -dontwarn android.support.v4.** solves the problem, but I'd like an more specific/elegant solution, than ignoring all problems on support.v4 package

Can anybody tell what rules should be added, so these classes/@interfaces are correctly processed by Proguard?

1
  • 1
    even i faced this issue a lot of times, but the only solution i could is using -dontwarn Commented Jun 9, 2015 at 5:42

2 Answers 2

16

The only solution is what you have mentioned, i.e -dontwarn android.support.v4.**. This is actually taken from the <path-to-android-sdk>/tools/proguard/proguard-android.txt, where it says:

# 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.** 
Sign up to request clarification or add additional context in comments.

Comments

4

It is safe to set don't warn for the support library classes according to the Android team. You can do this via:

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

7 Comments

What problem? Is your app crashing?
No, but the build is, and that worries me
Isn't that just due to warnings?
@MarekSebera the answer is given by Google itself in the proguard-android.txt inside <path-to-android-sdk>/tools/proguard/. It says # 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.
@Sufian make your comment into answer and I'll accept it as correct answer, this answer is not entirely same as the contents of proguard-android.txt, so it's your chance
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.