It promotes reusability, testability and maintainability.

There is any DI for Android?

Yes, there are many
libraries, which support injection in android.

Listed beloware used the most in this space.

RoboGuice is a framework that brings
the simplicity and ease of Dependency Injection to Android, using Google's own
Guice library.If you've
ever used Spring (the #1 enterprise framework on Java, now more popular than
J2EE itself) or Guice, you already know how convenient this style of
programming can be.

AndroidAnnotations is an Open Source framework that speeds up Android development. It takes care of the plumbing, and lets you concentrate on what's really important. By simplifying your code, it facilitates its maintenance.

No magic: As AndroidAnnotations generate subclasses at compile time, you can check the code to see how it works.

AndroidAnnotations provide those good things and even more for less than 50kb, without any runtime perf impact!

Fast dependency injector for
Android and Java.

Dagger is a replacement for theseFactoryFactoryclasses. It allows you to focus on the interesting
classes. Declare dependencies, specify how to satisfy them, and ship your app. By building on
standardjavax.injectannotations (JSR-330), each class is easy
to test. You don't need a bunch of boilerplate
just to swap theRpcCreditCardServiceout for aFakeCreditCardService.

Dependency
injection isn't just for testing. It also makes it easy to create reusable,
interchangeable modules.

Compile Time Code Generation - Transfuse is remarkably small,
lightweight and fast due to the technique of generating supporting code at
compile time.

All of these features help eliminate boilerplate plumbing code and make
Android applications much easier to write.

Which is the best Dependency Injection
Framework?

It’s purely depending on the usage of your project.

For Example:

In android, if I want to avoid the boilerplate code such as injection of views, view holder in
adapter and click listeners then the preferred
library can be ButterKnife compare to others because remaining all done more
than the required. There are tons of features which are not used added in all
these libraries.

AndroidAnnotations
and ButterKnife does the similar work.

RoboGuice, Dagger and Transfuse are in the same
category.

We will take one from each, say RoboGuice vs ButterKnife.Let see, which is better for the example taken.

Code License

Origin

Sample Source Code

Avoid dependency injection
frameworks

Using a dependency injection
framework such as Guice or RoboGuice may be
attractive because they can simplify the code you write and provide an adaptive
environment that's useful for testing and other configuration changes.

Be careful about using external
libraries

External library code is often not
written for mobile environments and can be inefficient when used for work on a
mobile client.

Source Code

You can download the source code by clicking the links provided
in the comparison table. This project is built using eclipse
IDE. Unzip and import the project into Eclipse, it’s a good idea to use the
Project by clean and rebuild from the project menu.

Thanks for reading :)

Whether this post is
helpful?

Have something to add to this
post? If you have any other quick thoughts/hints that you think people will
find useful? Share it in the comments.