Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dagger android support proguard rules

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 ?

like image 302
Mahdi Nouri Avatar asked Aug 27 '17 18:08

Mahdi Nouri


People also ask

Why Dagger is used in Android?

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.

What is Android ProGuard rules?

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.

What is dagger dependency injection Android?

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.

What is use of dagger?

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.


1 Answers

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.**
like image 57
Xavier Rubio Jansana Avatar answered Sep 19 '22 09:09

Xavier Rubio Jansana