Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android design support library proguard rules

Have been trying to find some information about the rules needed for the new design support library to work passing proguard. I couldn't find any information about it.

Ended up using these rules:

-keep class android.support.design.widget.** { *; }
-keep interface android.support.design.widget.** { *; }
-dontwarn android.support.design.**

These rules seem to work but I'm not really sure if there are better rules or if it works with all the classes inside the design support library

like image 735
Carlos Morera Avatar asked Jun 10 '15 22:06

Carlos Morera


People also ask

How do you write ProGuard rules in Android?

When you create a new project or module using Android Studio, the IDE creates a <module-dir>/proguard-rules.pro file for you to include your own rules. You can also include additional rules from other files by adding them to the proguardFiles property in your module's build. gradle file.

What is Android ProGuard rules?

ProGuard is a tool to help minify, obfuscate, and optimize your code. It is not only especially useful for reducing the overall size of your Android application as well as removing unused classes and methods that contribute towards the intrinsic 64k method limit of Android applications.

Should I use R8 or ProGuard?

R8 is having a faster processing time than Proguard which reduces build time. R8 gives better output results than Proguard. R8 reduces the app size by 10 % whereas Proguard reduces app size by 8.5 %. The android app having a Gradle plugin above 3.4.

Where do you put ProGuard rules?

Android Studio adds the proguard-rules.pro file at the root of the module, so you can also easily add custom ProGuard rules specific to the current module. You can also add ProGuard files to the getDefaultProguardFile directive for all release builds or as part of the productFlavor settings in the build.


2 Answers

I meet this error error while parsing android/support/design/R$anim.class.

End it with this code:

# support design
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
like image 138
MewX Avatar answered Oct 08 '22 01:10

MewX


This should work:

-keep public class * extends android.support.design.widget.CoordinatorLayout$Behavior {
    public <init>(android.content.Context, android.util.AttributeSet);
}
like image 22
Yuichi Araki Avatar answered Oct 08 '22 01:10

Yuichi Araki