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 ?
In Android, you usually create a Dagger graph that lives in your application class because you want an instance of the graph to be in memory as long as the app is running. In this way, the graph is attached to the app lifecycle. In some cases, you might also want to have the application context available in the graph.
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.
Dagger 2 is a compile-time android dependency injection framework that uses Java Specification Request 330 and Annotations. Some of the basic annotations that are used in dagger 2 are: @Module This annotation is used over the class which is used to construct objects and provide the dependencies.
Dagger is arguably the most used Dependency Injection, or DI, framework for Android. Many Android projects use Dagger to simplify building and providing dependencies across the app. It gives you the ability to create specific scopes, modules, and components, where each forms a piece of a puzzle: The dependency graph.
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.**
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