When to use Dagger in android application?

I know that Dagger is a dependency injection framework, but I have not still used it in my projects.

I am starting a new project and wondering if Dagger is suitable for it. As far as I understand, using of Dagger leads to a lot of boilerplate code and annotations.
So I am not sure if it is not an overkill for my relatively simple project.

  • Android Studio update 0.5.3 - platform 'android-19' not found
  • Difference between a View's Padding and Margin
  • Applying ColorFilter to ImageView with ShapedDrawable
  • Static way to get 'Context' on Android?
  • android application dequeuebuffer error on snapdragon device
  • How to append to a text file in android?
  • A bit about the project. It is focused on image processing and main part of functionality is built around it. However, it will also probably have a simple backend for data storage.

    In general, I would like to know some basic principles that I can use to choose using Dagger for a project or not.

    Related posts:

    What methods are invoked in the Activity Lifecycle in the following cases:
    Caused by: java.lang.UnsatisfiedLinkError: Cannot load library
    How to automatically increase and release signed apk in Android Studio using Gradle script
    Retrofit connection failure returns RetrofitError.response as null
    ZXing Android Generate 1D barcode
    Detect hidden/not visible bluetooth device on mobile
  • Action items from Viewpager initial fragment not being displayed
  • How to get access to phonegap API from a remote page
  • Hide keyboard in AlertDialog
  • using a custom color for button background while using selectableItemBackground attribute
  • Pass variables between renderer and another class with queueEvent()
  • How to authenticate multiple accounts in Android dropbox sdk 1.5.1?
  • One Solution collect form web for “When to use Dagger in android application?”

    Basic Understanding:

    Suppose, you want to test your application that deals with Credit Card service. For testing purpose you must not want to Access a real RPCCreditCardService as it will need real transaction and other stuffs that you don’t want to perform during development. In that case you must had to create a clone fake service that will mimic the same thing that real CreditCardService does but not transact anything. If you use the dependency injection framework you can define common tasks in a dependency and inject it in both fake and real service. It will minimize coding complexity as well as helps to make each module independent.

    From the documentation:

    By using dependency injection framework, each class is easy to test. You don’t need a bunch of boilerplate just to swap the RpcCreditCardService out for a FakeCreditCardService.

    Dependency injection isn’t just for testing. It also makes it easy to create reusable, interchangeable modules. You can share the same AuthenticationModule across all of your apps. And you can run DevLoggingModule during development and ProdLoggingModule in production to get the right behavior in each situation.


    For more detailed understanding you can check this discussion.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.