Dagger and Butter Knife vs. Android Annotations

前端 未结 8 826
抹茶落季
抹茶落季 2021-01-29 23:54

I am evaluating Dependency Injection (DI) frameworks for an Android app. The top contenders are: Dagger (with Butter Knife) and Android Annotations. I understand that Dagger an

相关标签:
8条回答
  • 2021-01-30 00:42

    Eventually if you use one of the three, you'll have a hard time transitioning to Android's databinding. That's what's fastest if you need to consider performance:

    https://developer.android.com/tools/data-binding/guide.html

    0 讨论(0)
  • 2021-01-30 00:44

    The reddit-thread mentioned by @ChrLipp has someone who used all three on the same project, speaks highly of dagger+butterknife but also gives AndroidAnnotations its place:

    For dependency injection, butterknife is used for Views, Dagger is used for all objects and is highly recommended and Android Annotations creates more of a framework for developing Android instead of injecting objects into your classes so each library are quite different from each other. Dagger is equivalent to Guice but is much much faster. Dagger is more powerful then ButterKnife and Android Annotations as it injects all objects rather than ButterKnife and Android Annotations which only inject a certain set of objects.

    Dagger can be a pain to setup and configure but is well worth it once you have it done. But then again, because these are all quite different from each other, it all depends on what your needs are for the project.

    Also, speaking of each one being quite different, in your project you can use ButterKnife, Android Annotations and Dagger all in the same project if you really want to. They each have the same idea but do something different so you could use them all.

    0 讨论(0)
提交回复
热议问题