Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Butterknife vs AndroidAnnotations [closed]

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?

like image 479
AdrianoCelentano Avatar asked Jan 22 '14 10:01

AdrianoCelentano


1 Answers

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.

like image 181
sergej shafarenka Avatar answered Nov 16 '22 12:11

sergej shafarenka