How to configure ProGuard settings for ButterKnife 8?

I am running ButterKnife 8.5.1 in my Android application. If I try to make ProGuard settings for ButterKnife, I still have crashes in my version. There is a problem on the official ButterKnife Github page that says you are making the following settings:

-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }

-keepclasseswithmembernames class * {
     @butterknife.* <fields>;
}

-keepclasseswithmembernames class * {
    @butterknife.* <methods>;
}

Alternatively, it is written to use the following settings:

# Butterknife
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector { *; }
-keepnames class * { @butterknife.InjectView *;}

None of them work with my configuration. I still had crashes when accessing Views related to ButterKnife. So, are there any new settings you need to make for ButterKnife 8?

+4
source share
2

ButterKnife 8 . ProGuard 7 8 :

###---------------Begin: proguard configuration for ButterKnife  ----------
# For Butterknife:
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**

# Version 7
-keep class **$$ViewBinder { *; }
# Version 8
-keep class **_ViewBinding { *; }

-keepclasseswithmembernames class * { @butterknife.* <fields>; }
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
###---------------End: proguard configuration for ButterKnife  ----------

@OnClick, . . !

+3

:

-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
-keep public class * implements butterknife.internal.ViewBinder { public <init>(); }
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
-keep class **$$ViewBinder { *; }
-keep class **$ViewHolder { *; }
-keep class butterknife.**$Finder { *; }
-keep class **_ViewBinding { *; }

, , butterknife build.gradle annotationProcessor .

0

Source: https://habr.com/ru/post/1673124/


All Articles