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.

  • Rounded corners with Picasso
  • Update data in ListFragment as part of ViewPager
  • Android detect phone lock event
  • Android studio AssertionError: Don't invoke waitForSmartMode from inside read action in dumb mode
  • Switch crashes when clicked on Android 5.0
  • Why use armeabi-v7a code over armeabi code?
  • 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.

  • Android translate animation - permanently move View to new position using AnimationListener
  • Android: adb pull file on desktop
  • how can I detect whether the android phone in Silent mode programmatically
  • Datepicker dialog without calendar visualization in lollipop ?
  • Android MediaPlayer error (1, -2147483648)
  • .length() vs .getText().length() vs .getText().toString().length()
  • 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.

    Reference:

    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.