I've been building an Android app using Butterknife and recently upgraded to 7.0.1. I replaced all the @InjectView
and ButterKnife.inject
usage with the new @Bind
feature and have no problems with debug builds but the app crashes on startup for release builds.
If I switch 'minifyEnabled
' to false in my build.gradle then I can generate a working release build.
I'm using the proguard configuration thats documented on the Butterknife site but it doesn't appear to be working for me. I'm also using Dagger, Picasso and Flurry in my build.
My proguard-rules.pro contents:
# ButterKnife
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
@butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
@butterknife.* <methods>;
}
# Dagger
-keepclassmembers,allowobfuscation class * {
@javax.inject.* *;
@dagger.* *;
<init>();
}
-keep class javax.inject.** { *; }
-keep class **$$ModuleAdapter
-keep class **$$InjectAdapter
-keep class **$$StaticInjection
-keep class dagger.** { *; }
# Picaso
-dontwarn com.squareup.okhttp.**
# Flurry
-keep class com.flurry.** { *; }
-dontwarn com.flurry.**
We had similar problems after upgrading to 7.0.1 but we got an ANR instead.
The problem seems to be because we replaced the Butterknife section of Proguard with the new recommended options from the ButterKnife website.
Adding -keepnames class * { @butterknife.Bind *;}
to the proguard file has fixed our issues.
From the website, http://jakewharton.github.io/butterknife/ this seemed to work for me:
-keep class butterknife.** { *; }
-dontwarn butterknife.internal.**
-keep class **$$ViewBinder { *; }
-keepclasseswithmembernames class * {
@butterknife.* <fields>;
}
-keepclasseswithmembernames class * {
@butterknife.* <methods>;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With