tiagoMissiato
tiagoMissiato

Reputation: 335

AndroidAnnotations and Dagger 2

I'm reading about Dependency Injections and found 2 libs that get my attention, AndroidAnnotations and Dagger 2. What I saw is that AA has a lot of functionalities including DI, but most of the developers are using Dagger 2 for DI.

I was wondering what is the diference between DI with AA and DI with Dagger 2? If I use AA it means I don't need Dagger 2?

I couldn't find much information for DI with AA and comparison with other libraries.

Any info would help a lot.

Upvotes: 4

Views: 989

Answers (2)

Satiswar Dash
Satiswar Dash

Reputation: 73

recently I have created one sample application by implementing Dagger 2 and Android Architectural Components (Room and Viewmodel) which can help you understand dependency injection using dagger library along with MVVM architecture.

Here is the github project link

Upvotes: 0

WonderCsabo
WonderCsabo

Reputation: 12197

I do not think AA and Dagger can be compared.

Dagger is a general dependency injection library, with lots of capabilities. It is designed to run on Android as well, but it does not need Android, it can be applied on pure Java projects. It has lots of dependency injection features for a fully code-generation based dependency injector.

AndroidAnnotations is an annotation-based framework for Android. It does have a limited dependency injection module (which is only a small subset of AA), however that is not its main feature. It adds annotation based, boilerplate removing APIs for lots of thing for Android, which are used in every project and normally require an awful lot of unnecessary code, like view and resource injection, event handling, instance state restoration, threading, etc. You can see all the use cases of AA here.

Dagger and AA can coexist, actually it really makes sense to use the sophisticated dep injection from Dagger and the lot of features of AA together (i do in all of my projects).

Disclaimer: i am an AndroidAnnotations developer.

Upvotes: 5

Related Questions