1

Since Butterknife uses reflection to generate classes associating with every activity or fragment used. due to which Proguard ignores those classes and not obfuscate it in its rules.

found one work around to this is to use Butterknife generated classes by Replacing ButterKnife.bind(this) with new Whatever_ViewBinder(this) and use them in my code. which does work and Progurad obfuscate my classes. but only problem here is i have to copy them from Debug folder to my package from getting changed/deleted. and update it every time i add/remove views. source

another question i found which says it better to use Data binding instead Butterknife vs Data Binding. but its too late now for me to change the whole code

Please share across if you'll have found any work around to this. I am using Butterknife v8.6.0. if this is of any help

Jolson Da Costa
  • 1,095
  • 1
  • 12
  • 31

1 Answers1

2

You even linked to your answers yourself with #746.

[...] until I remove all imports of Butter Knife from the class, Proguard doesn't work on it.

This is because the Proguard rules are supplied with Butter Knife itself until version 9.0.

The ProGuard rules will be separated in 9.0 when using the generated code API becomes stable.

So basically it's not possible to do easily what you're intending to do. The best would be to fork Butter Knife and remove the consumerProguardFiles definition from build.gradle. Then wait for version 9.0 to be released and then use the original again.

tynn
  • 38,113
  • 8
  • 108
  • 143