dagger android support proguard rules

Mahdi Nouri picture Mahdi Nouri · Aug 27, 2017 · Viewed 7.9k times · Source

I'm using Dagger2 android-support library with Proguard but i can't compile my project because of this error :

Warning:dagger.android.AndroidInjector: can't find referenced class com.google.errorprone.annotations.DoNotMock
Warning:dagger.android.AndroidInjector$Builder: can't find referenced class com.google.errorprone.annotations.DoNotMock
Warning:dagger.android.AndroidInjector$Factory: can't find referenced class com.google.errorprone.annotations.DoNotMock
Warning:dagger.android.DaggerApplication: can't find referenced class com.google.errorprone.annotations.ForOverride
Warning:dagger.android.DispatchingAndroidInjector: can't find referenced class com.google.errorprone.annotations.CanIgnoreReturnValue
Warning:there were 5 unresolved references to classes or interfaces.

The version of Dagger that I'm using is 2.11.

The question is what Proguard rules should i use for Dagger2 android-support library ?

Answer

Xavier Rubio Jansana picture Xavier Rubio Jansana · Aug 27, 2017

Should be:

-keep class com.google.errorprone.annotations.** { *; }

Update: Probably the following rule alone is enough, no need to add previous rule.

-dontwarn com.google.errorprone.annotations.**