Question

I'm thinking about using Dagger in my Application. I also want to use a view injection library which gives me a lot of functionality to save time writing code, but on the other hand it shouldn't be to heavy in size and expensive when it comes to performance.

Are there any major differences between AndroidAnnotations and Butterknife?

Was it helpful?

Solution

If you just want to reduce boilerplate code in your application by inject views (or setting click listeners), you can start with Butterknife. It's fast, small in size and straightforward in use. It's intended to inject views, listeners and other UI related objects.

If you want to inject more stuff like system services, or force methods to run in background or UI thread, or inject resources like animations etc. you should go after AndroidAnnotations. Small disadvantage you will face is that for each class you want to enhance a new class will be generated with the same name plus "_" at the end. Thus you will have to get used to use such names when calling activities or creating fragments. If this is not an issue for you, just use it. Both libraries generate code, so you should not have any performance penalties at runtime.

Dagger is not intended for views injection. Dagger allows you to better structure your code and define injectable dependencies between different components. It's very powerful if you master it, but it does not replace Butterknife.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top