Dagger and Butter Knife vs. Android Annotations












62















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 and ButterKnife are from the same source- square and they complement each other. Here're are the key matrices that I am looking for:




  1. Ease of use (our build is based on Gradle and we use Android Studio IDE)

  2. Testing support (we use Robotium for functional testing and RoboLectric for unit testing)

  3. Performance (DI frameworks use reflection, which one is faster?)










share|improve this question




















  • 4





    google specifically asks not to use dependency injection developer.android.com/training/articles/memory.html#Android

    – Illegal Argument
    Jun 22 '14 at 13:44






  • 7





    @IllegalArgument that link just says "those frameworks tend to do a lot of initialization process to scan annotations". Dagger and AndroidAnnotations (probably also Butter Knife as it claims but I'm not sure) all do their magic at compile time that may not be applicable.

    – kizzx2
    Jun 27 '14 at 12:33











  • See reddit.com/r/androiddev/comments/28vlrt/…

    – ChrLipp
    Sep 29 '14 at 11:54






  • 2





    Note: both Dagger and Android Annotations don't use reflection.

    – Siebe
    Sep 30 '14 at 7:31











  • Unbiased by-the-numbers comparison: codix.io/cmp/Android%20Dependency%20Injection%20Libraries

    – Nick
    Feb 3 '17 at 16:19
















62















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 and ButterKnife are from the same source- square and they complement each other. Here're are the key matrices that I am looking for:




  1. Ease of use (our build is based on Gradle and we use Android Studio IDE)

  2. Testing support (we use Robotium for functional testing and RoboLectric for unit testing)

  3. Performance (DI frameworks use reflection, which one is faster?)










share|improve this question




















  • 4





    google specifically asks not to use dependency injection developer.android.com/training/articles/memory.html#Android

    – Illegal Argument
    Jun 22 '14 at 13:44






  • 7





    @IllegalArgument that link just says "those frameworks tend to do a lot of initialization process to scan annotations". Dagger and AndroidAnnotations (probably also Butter Knife as it claims but I'm not sure) all do their magic at compile time that may not be applicable.

    – kizzx2
    Jun 27 '14 at 12:33











  • See reddit.com/r/androiddev/comments/28vlrt/…

    – ChrLipp
    Sep 29 '14 at 11:54






  • 2





    Note: both Dagger and Android Annotations don't use reflection.

    – Siebe
    Sep 30 '14 at 7:31











  • Unbiased by-the-numbers comparison: codix.io/cmp/Android%20Dependency%20Injection%20Libraries

    – Nick
    Feb 3 '17 at 16:19














62












62








62


25






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 and ButterKnife are from the same source- square and they complement each other. Here're are the key matrices that I am looking for:




  1. Ease of use (our build is based on Gradle and we use Android Studio IDE)

  2. Testing support (we use Robotium for functional testing and RoboLectric for unit testing)

  3. Performance (DI frameworks use reflection, which one is faster?)










share|improve this question
















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 and ButterKnife are from the same source- square and they complement each other. Here're are the key matrices that I am looking for:




  1. Ease of use (our build is based on Gradle and we use Android Studio IDE)

  2. Testing support (we use Robotium for functional testing and RoboLectric for unit testing)

  3. Performance (DI frameworks use reflection, which one is faster?)







android dependency-injection dagger android-annotations butterknife






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 3 '15 at 11:01









serv-inc

13.8k56985




13.8k56985










asked Jun 22 '14 at 13:39









user3277846user3277846

5441714




5441714








  • 4





    google specifically asks not to use dependency injection developer.android.com/training/articles/memory.html#Android

    – Illegal Argument
    Jun 22 '14 at 13:44






  • 7





    @IllegalArgument that link just says "those frameworks tend to do a lot of initialization process to scan annotations". Dagger and AndroidAnnotations (probably also Butter Knife as it claims but I'm not sure) all do their magic at compile time that may not be applicable.

    – kizzx2
    Jun 27 '14 at 12:33











  • See reddit.com/r/androiddev/comments/28vlrt/…

    – ChrLipp
    Sep 29 '14 at 11:54






  • 2





    Note: both Dagger and Android Annotations don't use reflection.

    – Siebe
    Sep 30 '14 at 7:31











  • Unbiased by-the-numbers comparison: codix.io/cmp/Android%20Dependency%20Injection%20Libraries

    – Nick
    Feb 3 '17 at 16:19














  • 4





    google specifically asks not to use dependency injection developer.android.com/training/articles/memory.html#Android

    – Illegal Argument
    Jun 22 '14 at 13:44






  • 7





    @IllegalArgument that link just says "those frameworks tend to do a lot of initialization process to scan annotations". Dagger and AndroidAnnotations (probably also Butter Knife as it claims but I'm not sure) all do their magic at compile time that may not be applicable.

    – kizzx2
    Jun 27 '14 at 12:33











  • See reddit.com/r/androiddev/comments/28vlrt/…

    – ChrLipp
    Sep 29 '14 at 11:54






  • 2





    Note: both Dagger and Android Annotations don't use reflection.

    – Siebe
    Sep 30 '14 at 7:31











  • Unbiased by-the-numbers comparison: codix.io/cmp/Android%20Dependency%20Injection%20Libraries

    – Nick
    Feb 3 '17 at 16:19








4




4





google specifically asks not to use dependency injection developer.android.com/training/articles/memory.html#Android

– Illegal Argument
Jun 22 '14 at 13:44





google specifically asks not to use dependency injection developer.android.com/training/articles/memory.html#Android

– Illegal Argument
Jun 22 '14 at 13:44




7




7





@IllegalArgument that link just says "those frameworks tend to do a lot of initialization process to scan annotations". Dagger and AndroidAnnotations (probably also Butter Knife as it claims but I'm not sure) all do their magic at compile time that may not be applicable.

– kizzx2
Jun 27 '14 at 12:33





@IllegalArgument that link just says "those frameworks tend to do a lot of initialization process to scan annotations". Dagger and AndroidAnnotations (probably also Butter Knife as it claims but I'm not sure) all do their magic at compile time that may not be applicable.

– kizzx2
Jun 27 '14 at 12:33













See reddit.com/r/androiddev/comments/28vlrt/…

– ChrLipp
Sep 29 '14 at 11:54





See reddit.com/r/androiddev/comments/28vlrt/…

– ChrLipp
Sep 29 '14 at 11:54




2




2





Note: both Dagger and Android Annotations don't use reflection.

– Siebe
Sep 30 '14 at 7:31





Note: both Dagger and Android Annotations don't use reflection.

– Siebe
Sep 30 '14 at 7:31













Unbiased by-the-numbers comparison: codix.io/cmp/Android%20Dependency%20Injection%20Libraries

– Nick
Feb 3 '17 at 16:19





Unbiased by-the-numbers comparison: codix.io/cmp/Android%20Dependency%20Injection%20Libraries

– Nick
Feb 3 '17 at 16:19












9 Answers
9






active

oldest

votes


















52














AndroidAnnotations

uses compile time annotation processing. It generates a sub class with an underscore apppended to the original name (MyActivity_ generated from MyActivity). So to have it work you always have to use the generated class for references instead of your original class.



It has a very rich feature set, see the list of available annotations.



Butterknife

uses also compile time annotation processing, but it generates finder classes which are used by a central class (ButterKnife). This means that you can use your original class for referencing, but you have to call the injection manually. A copy from the ButterKnife introduction:



@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_activity);
ButterKnife.inject(this);
// TODO Use "injected" views...
}


The feature set is not so rich, ButterKnife supports view injection (AndroidAnnotations equivalent would be @ViewByIdand @ViewsById) and some event binding (for a complete list see the namespace directory here, just count the OnXXX event annotations).



Dagger

is a DI implementation for Android, similar to Guice. It also uses compile time annotation processing and generates object graphs which you use for manually injection. You distinguish between application object graph and scoped object graphs for injecting e.g. in activities. Here you see an Application.onCreate example:



@Override public void onCreate() {
super.onCreate();
objectGraph = ObjectGraph.create(getModules().toArray());
objectGraph.inject(this);
// use injected classes
}


I found it is harder to start with dagger, but this might be only my experience. However see some videos here for a better start: 1, 2



From the feature set point of view I would say that Dagger implements functionalities which could be compared to AndroidAnnotation's @EBean and @Bean functionality.



Summary

If you are comparing ease of use, testing support and performance I can't find much difference between using AndroidAnnotation and ButterKnife+Dagger. Differences are in the programming model (use classes with _ instead of using the original ones and call the injection manually) and in the feature set.



AndroidAnnotation gives you a full list of functionalities, but ties you to certain libraries. For example if you use it's rest api you have to use Spring Android. You also have annotations for features like OrmLite (@OrmLiteDao) regardless if you use OrmLite or not.



At the end it is a matter of taste, at least in my opinion.






share|improve this answer


























  • I think you made a mistake about ButterKnife: it uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time.

    – ech0s7r
    Oct 7 '14 at 11:00






  • 3





    I think that all solutions produce code during the compile time and this code is called (at runtime) to perform the injection. In Android Annotations for example it generates a subclass (MyActivity_) which performs the injection for MyActivity. In Butterknife you have to call ButterKnife.inject(this) which delegates to the generated code.

    – ChrLipp
    Nov 6 '14 at 9:47













  • No love for Android's own Data binding library? developer.android.com/tools/data-binding/guide.html You'll eventually forget all that.

    – Pier Betos
    Apr 28 '16 at 15:26








  • 1





    Sorry for digging out. the last paragraph is no more correct. Android Annotations is now modular, so you can include OrmLite-Support just if you really use OrmLite.

    – r00tandy
    Jan 7 '17 at 12:20



















19














Here is the Nice article in Dzone blog.



We to need to compare the features of each, such as :





  • Minimum Jars required

  • ActionBarSherlock compatibility

  • Injection for click listeners

  • POJO injection

  • Performance




enter image description here



Only Pojo Injection missing in butterknife! So looks like Butterknife is the winner!



Source






share|improve this answer





















  • 1





    Another row I would consider adding to this chart is "Support for Library Projects" which Butterknife does not support, but AndroidAnnotations does via the resName attribute (see github.com/excilys/androidannotations/wiki/Library-projects). This was a dealbreaker for me using Butterknife.

    – John D.
    Jan 22 '15 at 19:49











  • -1: the question was not about RoboGuice (which is anyway retired and not maintained any longer), but about AndroidAnnotations

    – TmTron
    Aug 23 '16 at 15:23





















6














Google does ask specifically not to use dependency injection.



But by reading their request they seem to be referring more to the Guice and reflection based DI library's. Libraries such as android annotation use no reflection instead employing compile time generated code, while butterknife and dagger uses a small amount of reflection optimised for android but are supposedly slightly more powerful than android annotation. It really depends on the project and how much of a performance hit you are willing to take. In my opinion just using butterknife is sufficient to speed up code development by itself. If you need slightly more use android annotation and lastly if you are willing to take a slight performance hit due to reflection the best option without absolutely destroying performance with a powerhouse Guice based reflection use dagger + butterknife.






share|improve this answer





















  • 10





    Google is jointly developing dagger2: google.github.io/dagger

    – serv-inc
    Jul 3 '15 at 10:45








  • 1





    They made their own, that's why: developer.android.com/tools/data-binding/guide.html youtube.com/watch?v=5sCQjeGoE7M

    – Pier Betos
    Apr 28 '16 at 15:32





















5














You should give a try at Toothpick.



Toothpick is (per the README):




  • pure java

  • fast, it doesn't use reflection but annotation processing

  • simple, flexible, extensible & powerful, robust & tested

  • thread safe

  • documented & Open Source

  • scope safe : it enforces leak free apps

  • test oriented : it makes tests easier

  • it works very well with Android or any other context based framework (such as web containers)


It can even be faster than Dagger 2 in most cases, and it's much simpler.



Note: Yes, I am one of the authors.






share|improve this answer
























  • Can we use Android annotation processor for Toothpick?

    – Yousha Aleayoub
    Jan 15 at 21:08



















3














Use Android Annotations or Butterknife to ease your coding. But don't go for Roboguice! Roboguice forces your activies, fragments to extend to roboguice classes. Not fun, at all!



Dagger 2 is a much better option. You can use it along with Android Annotations if you'd like. I would just use Android Annotations for a simple app, but these days is good to work more with Dagger.






share|improve this answer


























  • Whats the problem in extending from RoboActivity (that extends from Activity) while you can extend from Activity? you are not losing anything here.

    – vijay
    Oct 9 '17 at 17:55











  • It's an old library. It used to force you to use their Android component flavors. Now the best option is Dagger 2. Good luck.

    – Juan Mendez
    Nov 12 '18 at 23:55





















1














Seems like Google chooses dagger, as they are developing it jointly with Square, who created it.



Concerning Butterknife and Dagger themselves, there is the SO question difference-between-dagger-and-butterknife-android which clarifies how they complement each other.






share|improve this answer

































    1














    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.







    share|improve this answer































      1














      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






      share|improve this answer































        0














        I think the better between (in terms of performance) ButterKnife and AndroidAnnotation is the second. ButterKnife uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time. Instead, AndroidAnnotations, process all annotations at compile time.






        share|improve this answer



















        • 4





          "ButterKnife inject code at runtime" - Are you sure?

          – naXa
          Jun 19 '15 at 6:42











        • Read first para of this article thekeyconsultant.com/2013/09/…

          – Redman
          Apr 17 '17 at 6:58











        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24351817%2fdagger-and-butter-knife-vs-android-annotations%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        9 Answers
        9






        active

        oldest

        votes








        9 Answers
        9






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        52














        AndroidAnnotations

        uses compile time annotation processing. It generates a sub class with an underscore apppended to the original name (MyActivity_ generated from MyActivity). So to have it work you always have to use the generated class for references instead of your original class.



        It has a very rich feature set, see the list of available annotations.



        Butterknife

        uses also compile time annotation processing, but it generates finder classes which are used by a central class (ButterKnife). This means that you can use your original class for referencing, but you have to call the injection manually. A copy from the ButterKnife introduction:



        @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_activity);
        ButterKnife.inject(this);
        // TODO Use "injected" views...
        }


        The feature set is not so rich, ButterKnife supports view injection (AndroidAnnotations equivalent would be @ViewByIdand @ViewsById) and some event binding (for a complete list see the namespace directory here, just count the OnXXX event annotations).



        Dagger

        is a DI implementation for Android, similar to Guice. It also uses compile time annotation processing and generates object graphs which you use for manually injection. You distinguish between application object graph and scoped object graphs for injecting e.g. in activities. Here you see an Application.onCreate example:



        @Override public void onCreate() {
        super.onCreate();
        objectGraph = ObjectGraph.create(getModules().toArray());
        objectGraph.inject(this);
        // use injected classes
        }


        I found it is harder to start with dagger, but this might be only my experience. However see some videos here for a better start: 1, 2



        From the feature set point of view I would say that Dagger implements functionalities which could be compared to AndroidAnnotation's @EBean and @Bean functionality.



        Summary

        If you are comparing ease of use, testing support and performance I can't find much difference between using AndroidAnnotation and ButterKnife+Dagger. Differences are in the programming model (use classes with _ instead of using the original ones and call the injection manually) and in the feature set.



        AndroidAnnotation gives you a full list of functionalities, but ties you to certain libraries. For example if you use it's rest api you have to use Spring Android. You also have annotations for features like OrmLite (@OrmLiteDao) regardless if you use OrmLite or not.



        At the end it is a matter of taste, at least in my opinion.






        share|improve this answer


























        • I think you made a mistake about ButterKnife: it uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time.

          – ech0s7r
          Oct 7 '14 at 11:00






        • 3





          I think that all solutions produce code during the compile time and this code is called (at runtime) to perform the injection. In Android Annotations for example it generates a subclass (MyActivity_) which performs the injection for MyActivity. In Butterknife you have to call ButterKnife.inject(this) which delegates to the generated code.

          – ChrLipp
          Nov 6 '14 at 9:47













        • No love for Android's own Data binding library? developer.android.com/tools/data-binding/guide.html You'll eventually forget all that.

          – Pier Betos
          Apr 28 '16 at 15:26








        • 1





          Sorry for digging out. the last paragraph is no more correct. Android Annotations is now modular, so you can include OrmLite-Support just if you really use OrmLite.

          – r00tandy
          Jan 7 '17 at 12:20
















        52














        AndroidAnnotations

        uses compile time annotation processing. It generates a sub class with an underscore apppended to the original name (MyActivity_ generated from MyActivity). So to have it work you always have to use the generated class for references instead of your original class.



        It has a very rich feature set, see the list of available annotations.



        Butterknife

        uses also compile time annotation processing, but it generates finder classes which are used by a central class (ButterKnife). This means that you can use your original class for referencing, but you have to call the injection manually. A copy from the ButterKnife introduction:



        @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_activity);
        ButterKnife.inject(this);
        // TODO Use "injected" views...
        }


        The feature set is not so rich, ButterKnife supports view injection (AndroidAnnotations equivalent would be @ViewByIdand @ViewsById) and some event binding (for a complete list see the namespace directory here, just count the OnXXX event annotations).



        Dagger

        is a DI implementation for Android, similar to Guice. It also uses compile time annotation processing and generates object graphs which you use for manually injection. You distinguish between application object graph and scoped object graphs for injecting e.g. in activities. Here you see an Application.onCreate example:



        @Override public void onCreate() {
        super.onCreate();
        objectGraph = ObjectGraph.create(getModules().toArray());
        objectGraph.inject(this);
        // use injected classes
        }


        I found it is harder to start with dagger, but this might be only my experience. However see some videos here for a better start: 1, 2



        From the feature set point of view I would say that Dagger implements functionalities which could be compared to AndroidAnnotation's @EBean and @Bean functionality.



        Summary

        If you are comparing ease of use, testing support and performance I can't find much difference between using AndroidAnnotation and ButterKnife+Dagger. Differences are in the programming model (use classes with _ instead of using the original ones and call the injection manually) and in the feature set.



        AndroidAnnotation gives you a full list of functionalities, but ties you to certain libraries. For example if you use it's rest api you have to use Spring Android. You also have annotations for features like OrmLite (@OrmLiteDao) regardless if you use OrmLite or not.



        At the end it is a matter of taste, at least in my opinion.






        share|improve this answer


























        • I think you made a mistake about ButterKnife: it uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time.

          – ech0s7r
          Oct 7 '14 at 11:00






        • 3





          I think that all solutions produce code during the compile time and this code is called (at runtime) to perform the injection. In Android Annotations for example it generates a subclass (MyActivity_) which performs the injection for MyActivity. In Butterknife you have to call ButterKnife.inject(this) which delegates to the generated code.

          – ChrLipp
          Nov 6 '14 at 9:47













        • No love for Android's own Data binding library? developer.android.com/tools/data-binding/guide.html You'll eventually forget all that.

          – Pier Betos
          Apr 28 '16 at 15:26








        • 1





          Sorry for digging out. the last paragraph is no more correct. Android Annotations is now modular, so you can include OrmLite-Support just if you really use OrmLite.

          – r00tandy
          Jan 7 '17 at 12:20














        52












        52








        52







        AndroidAnnotations

        uses compile time annotation processing. It generates a sub class with an underscore apppended to the original name (MyActivity_ generated from MyActivity). So to have it work you always have to use the generated class for references instead of your original class.



        It has a very rich feature set, see the list of available annotations.



        Butterknife

        uses also compile time annotation processing, but it generates finder classes which are used by a central class (ButterKnife). This means that you can use your original class for referencing, but you have to call the injection manually. A copy from the ButterKnife introduction:



        @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_activity);
        ButterKnife.inject(this);
        // TODO Use "injected" views...
        }


        The feature set is not so rich, ButterKnife supports view injection (AndroidAnnotations equivalent would be @ViewByIdand @ViewsById) and some event binding (for a complete list see the namespace directory here, just count the OnXXX event annotations).



        Dagger

        is a DI implementation for Android, similar to Guice. It also uses compile time annotation processing and generates object graphs which you use for manually injection. You distinguish between application object graph and scoped object graphs for injecting e.g. in activities. Here you see an Application.onCreate example:



        @Override public void onCreate() {
        super.onCreate();
        objectGraph = ObjectGraph.create(getModules().toArray());
        objectGraph.inject(this);
        // use injected classes
        }


        I found it is harder to start with dagger, but this might be only my experience. However see some videos here for a better start: 1, 2



        From the feature set point of view I would say that Dagger implements functionalities which could be compared to AndroidAnnotation's @EBean and @Bean functionality.



        Summary

        If you are comparing ease of use, testing support and performance I can't find much difference between using AndroidAnnotation and ButterKnife+Dagger. Differences are in the programming model (use classes with _ instead of using the original ones and call the injection manually) and in the feature set.



        AndroidAnnotation gives you a full list of functionalities, but ties you to certain libraries. For example if you use it's rest api you have to use Spring Android. You also have annotations for features like OrmLite (@OrmLiteDao) regardless if you use OrmLite or not.



        At the end it is a matter of taste, at least in my opinion.






        share|improve this answer















        AndroidAnnotations

        uses compile time annotation processing. It generates a sub class with an underscore apppended to the original name (MyActivity_ generated from MyActivity). So to have it work you always have to use the generated class for references instead of your original class.



        It has a very rich feature set, see the list of available annotations.



        Butterknife

        uses also compile time annotation processing, but it generates finder classes which are used by a central class (ButterKnife). This means that you can use your original class for referencing, but you have to call the injection manually. A copy from the ButterKnife introduction:



        @Override public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.simple_activity);
        ButterKnife.inject(this);
        // TODO Use "injected" views...
        }


        The feature set is not so rich, ButterKnife supports view injection (AndroidAnnotations equivalent would be @ViewByIdand @ViewsById) and some event binding (for a complete list see the namespace directory here, just count the OnXXX event annotations).



        Dagger

        is a DI implementation for Android, similar to Guice. It also uses compile time annotation processing and generates object graphs which you use for manually injection. You distinguish between application object graph and scoped object graphs for injecting e.g. in activities. Here you see an Application.onCreate example:



        @Override public void onCreate() {
        super.onCreate();
        objectGraph = ObjectGraph.create(getModules().toArray());
        objectGraph.inject(this);
        // use injected classes
        }


        I found it is harder to start with dagger, but this might be only my experience. However see some videos here for a better start: 1, 2



        From the feature set point of view I would say that Dagger implements functionalities which could be compared to AndroidAnnotation's @EBean and @Bean functionality.



        Summary

        If you are comparing ease of use, testing support and performance I can't find much difference between using AndroidAnnotation and ButterKnife+Dagger. Differences are in the programming model (use classes with _ instead of using the original ones and call the injection manually) and in the feature set.



        AndroidAnnotation gives you a full list of functionalities, but ties you to certain libraries. For example if you use it's rest api you have to use Spring Android. You also have annotations for features like OrmLite (@OrmLiteDao) regardless if you use OrmLite or not.



        At the end it is a matter of taste, at least in my opinion.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 30 '14 at 19:08

























        answered Sep 30 '14 at 17:16









        ChrLippChrLipp

        13.3k760101




        13.3k760101













        • I think you made a mistake about ButterKnife: it uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time.

          – ech0s7r
          Oct 7 '14 at 11:00






        • 3





          I think that all solutions produce code during the compile time and this code is called (at runtime) to perform the injection. In Android Annotations for example it generates a subclass (MyActivity_) which performs the injection for MyActivity. In Butterknife you have to call ButterKnife.inject(this) which delegates to the generated code.

          – ChrLipp
          Nov 6 '14 at 9:47













        • No love for Android's own Data binding library? developer.android.com/tools/data-binding/guide.html You'll eventually forget all that.

          – Pier Betos
          Apr 28 '16 at 15:26








        • 1





          Sorry for digging out. the last paragraph is no more correct. Android Annotations is now modular, so you can include OrmLite-Support just if you really use OrmLite.

          – r00tandy
          Jan 7 '17 at 12:20



















        • I think you made a mistake about ButterKnife: it uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time.

          – ech0s7r
          Oct 7 '14 at 11:00






        • 3





          I think that all solutions produce code during the compile time and this code is called (at runtime) to perform the injection. In Android Annotations for example it generates a subclass (MyActivity_) which performs the injection for MyActivity. In Butterknife you have to call ButterKnife.inject(this) which delegates to the generated code.

          – ChrLipp
          Nov 6 '14 at 9:47













        • No love for Android's own Data binding library? developer.android.com/tools/data-binding/guide.html You'll eventually forget all that.

          – Pier Betos
          Apr 28 '16 at 15:26








        • 1





          Sorry for digging out. the last paragraph is no more correct. Android Annotations is now modular, so you can include OrmLite-Support just if you really use OrmLite.

          – r00tandy
          Jan 7 '17 at 12:20

















        I think you made a mistake about ButterKnife: it uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time.

        – ech0s7r
        Oct 7 '14 at 11:00





        I think you made a mistake about ButterKnife: it uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time.

        – ech0s7r
        Oct 7 '14 at 11:00




        3




        3





        I think that all solutions produce code during the compile time and this code is called (at runtime) to perform the injection. In Android Annotations for example it generates a subclass (MyActivity_) which performs the injection for MyActivity. In Butterknife you have to call ButterKnife.inject(this) which delegates to the generated code.

        – ChrLipp
        Nov 6 '14 at 9:47







        I think that all solutions produce code during the compile time and this code is called (at runtime) to perform the injection. In Android Annotations for example it generates a subclass (MyActivity_) which performs the injection for MyActivity. In Butterknife you have to call ButterKnife.inject(this) which delegates to the generated code.

        – ChrLipp
        Nov 6 '14 at 9:47















        No love for Android's own Data binding library? developer.android.com/tools/data-binding/guide.html You'll eventually forget all that.

        – Pier Betos
        Apr 28 '16 at 15:26







        No love for Android's own Data binding library? developer.android.com/tools/data-binding/guide.html You'll eventually forget all that.

        – Pier Betos
        Apr 28 '16 at 15:26






        1




        1





        Sorry for digging out. the last paragraph is no more correct. Android Annotations is now modular, so you can include OrmLite-Support just if you really use OrmLite.

        – r00tandy
        Jan 7 '17 at 12:20





        Sorry for digging out. the last paragraph is no more correct. Android Annotations is now modular, so you can include OrmLite-Support just if you really use OrmLite.

        – r00tandy
        Jan 7 '17 at 12:20













        19














        Here is the Nice article in Dzone blog.



        We to need to compare the features of each, such as :





        • Minimum Jars required

        • ActionBarSherlock compatibility

        • Injection for click listeners

        • POJO injection

        • Performance




        enter image description here



        Only Pojo Injection missing in butterknife! So looks like Butterknife is the winner!



        Source






        share|improve this answer





















        • 1





          Another row I would consider adding to this chart is "Support for Library Projects" which Butterknife does not support, but AndroidAnnotations does via the resName attribute (see github.com/excilys/androidannotations/wiki/Library-projects). This was a dealbreaker for me using Butterknife.

          – John D.
          Jan 22 '15 at 19:49











        • -1: the question was not about RoboGuice (which is anyway retired and not maintained any longer), but about AndroidAnnotations

          – TmTron
          Aug 23 '16 at 15:23


















        19














        Here is the Nice article in Dzone blog.



        We to need to compare the features of each, such as :





        • Minimum Jars required

        • ActionBarSherlock compatibility

        • Injection for click listeners

        • POJO injection

        • Performance




        enter image description here



        Only Pojo Injection missing in butterknife! So looks like Butterknife is the winner!



        Source






        share|improve this answer





















        • 1





          Another row I would consider adding to this chart is "Support for Library Projects" which Butterknife does not support, but AndroidAnnotations does via the resName attribute (see github.com/excilys/androidannotations/wiki/Library-projects). This was a dealbreaker for me using Butterknife.

          – John D.
          Jan 22 '15 at 19:49











        • -1: the question was not about RoboGuice (which is anyway retired and not maintained any longer), but about AndroidAnnotations

          – TmTron
          Aug 23 '16 at 15:23
















        19












        19








        19







        Here is the Nice article in Dzone blog.



        We to need to compare the features of each, such as :





        • Minimum Jars required

        • ActionBarSherlock compatibility

        • Injection for click listeners

        • POJO injection

        • Performance




        enter image description here



        Only Pojo Injection missing in butterknife! So looks like Butterknife is the winner!



        Source






        share|improve this answer















        Here is the Nice article in Dzone blog.



        We to need to compare the features of each, such as :





        • Minimum Jars required

        • ActionBarSherlock compatibility

        • Injection for click listeners

        • POJO injection

        • Performance




        enter image description here



        Only Pojo Injection missing in butterknife! So looks like Butterknife is the winner!



        Source







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 11 '15 at 14:26









        RevanthKrishnaKumar V.

        1,48411530




        1,48411530










        answered Oct 1 '14 at 11:44









        LOG_TAGLOG_TAG

        14.6k96092




        14.6k96092








        • 1





          Another row I would consider adding to this chart is "Support for Library Projects" which Butterknife does not support, but AndroidAnnotations does via the resName attribute (see github.com/excilys/androidannotations/wiki/Library-projects). This was a dealbreaker for me using Butterknife.

          – John D.
          Jan 22 '15 at 19:49











        • -1: the question was not about RoboGuice (which is anyway retired and not maintained any longer), but about AndroidAnnotations

          – TmTron
          Aug 23 '16 at 15:23
















        • 1





          Another row I would consider adding to this chart is "Support for Library Projects" which Butterknife does not support, but AndroidAnnotations does via the resName attribute (see github.com/excilys/androidannotations/wiki/Library-projects). This was a dealbreaker for me using Butterknife.

          – John D.
          Jan 22 '15 at 19:49











        • -1: the question was not about RoboGuice (which is anyway retired and not maintained any longer), but about AndroidAnnotations

          – TmTron
          Aug 23 '16 at 15:23










        1




        1





        Another row I would consider adding to this chart is "Support for Library Projects" which Butterknife does not support, but AndroidAnnotations does via the resName attribute (see github.com/excilys/androidannotations/wiki/Library-projects). This was a dealbreaker for me using Butterknife.

        – John D.
        Jan 22 '15 at 19:49





        Another row I would consider adding to this chart is "Support for Library Projects" which Butterknife does not support, but AndroidAnnotations does via the resName attribute (see github.com/excilys/androidannotations/wiki/Library-projects). This was a dealbreaker for me using Butterknife.

        – John D.
        Jan 22 '15 at 19:49













        -1: the question was not about RoboGuice (which is anyway retired and not maintained any longer), but about AndroidAnnotations

        – TmTron
        Aug 23 '16 at 15:23







        -1: the question was not about RoboGuice (which is anyway retired and not maintained any longer), but about AndroidAnnotations

        – TmTron
        Aug 23 '16 at 15:23













        6














        Google does ask specifically not to use dependency injection.



        But by reading their request they seem to be referring more to the Guice and reflection based DI library's. Libraries such as android annotation use no reflection instead employing compile time generated code, while butterknife and dagger uses a small amount of reflection optimised for android but are supposedly slightly more powerful than android annotation. It really depends on the project and how much of a performance hit you are willing to take. In my opinion just using butterknife is sufficient to speed up code development by itself. If you need slightly more use android annotation and lastly if you are willing to take a slight performance hit due to reflection the best option without absolutely destroying performance with a powerhouse Guice based reflection use dagger + butterknife.






        share|improve this answer





















        • 10





          Google is jointly developing dagger2: google.github.io/dagger

          – serv-inc
          Jul 3 '15 at 10:45








        • 1





          They made their own, that's why: developer.android.com/tools/data-binding/guide.html youtube.com/watch?v=5sCQjeGoE7M

          – Pier Betos
          Apr 28 '16 at 15:32


















        6














        Google does ask specifically not to use dependency injection.



        But by reading their request they seem to be referring more to the Guice and reflection based DI library's. Libraries such as android annotation use no reflection instead employing compile time generated code, while butterknife and dagger uses a small amount of reflection optimised for android but are supposedly slightly more powerful than android annotation. It really depends on the project and how much of a performance hit you are willing to take. In my opinion just using butterknife is sufficient to speed up code development by itself. If you need slightly more use android annotation and lastly if you are willing to take a slight performance hit due to reflection the best option without absolutely destroying performance with a powerhouse Guice based reflection use dagger + butterknife.






        share|improve this answer





















        • 10





          Google is jointly developing dagger2: google.github.io/dagger

          – serv-inc
          Jul 3 '15 at 10:45








        • 1





          They made their own, that's why: developer.android.com/tools/data-binding/guide.html youtube.com/watch?v=5sCQjeGoE7M

          – Pier Betos
          Apr 28 '16 at 15:32
















        6












        6








        6







        Google does ask specifically not to use dependency injection.



        But by reading their request they seem to be referring more to the Guice and reflection based DI library's. Libraries such as android annotation use no reflection instead employing compile time generated code, while butterknife and dagger uses a small amount of reflection optimised for android but are supposedly slightly more powerful than android annotation. It really depends on the project and how much of a performance hit you are willing to take. In my opinion just using butterknife is sufficient to speed up code development by itself. If you need slightly more use android annotation and lastly if you are willing to take a slight performance hit due to reflection the best option without absolutely destroying performance with a powerhouse Guice based reflection use dagger + butterknife.






        share|improve this answer















        Google does ask specifically not to use dependency injection.



        But by reading their request they seem to be referring more to the Guice and reflection based DI library's. Libraries such as android annotation use no reflection instead employing compile time generated code, while butterknife and dagger uses a small amount of reflection optimised for android but are supposedly slightly more powerful than android annotation. It really depends on the project and how much of a performance hit you are willing to take. In my opinion just using butterknife is sufficient to speed up code development by itself. If you need slightly more use android annotation and lastly if you are willing to take a slight performance hit due to reflection the best option without absolutely destroying performance with a powerhouse Guice based reflection use dagger + butterknife.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 11 '18 at 9:16









        Oren Bochman

        504728




        504728










        answered Sep 26 '14 at 22:57









        ChadJPetersenChadJPetersen

        195214




        195214








        • 10





          Google is jointly developing dagger2: google.github.io/dagger

          – serv-inc
          Jul 3 '15 at 10:45








        • 1





          They made their own, that's why: developer.android.com/tools/data-binding/guide.html youtube.com/watch?v=5sCQjeGoE7M

          – Pier Betos
          Apr 28 '16 at 15:32
















        • 10





          Google is jointly developing dagger2: google.github.io/dagger

          – serv-inc
          Jul 3 '15 at 10:45








        • 1





          They made their own, that's why: developer.android.com/tools/data-binding/guide.html youtube.com/watch?v=5sCQjeGoE7M

          – Pier Betos
          Apr 28 '16 at 15:32










        10




        10





        Google is jointly developing dagger2: google.github.io/dagger

        – serv-inc
        Jul 3 '15 at 10:45







        Google is jointly developing dagger2: google.github.io/dagger

        – serv-inc
        Jul 3 '15 at 10:45






        1




        1





        They made their own, that's why: developer.android.com/tools/data-binding/guide.html youtube.com/watch?v=5sCQjeGoE7M

        – Pier Betos
        Apr 28 '16 at 15:32







        They made their own, that's why: developer.android.com/tools/data-binding/guide.html youtube.com/watch?v=5sCQjeGoE7M

        – Pier Betos
        Apr 28 '16 at 15:32













        5














        You should give a try at Toothpick.



        Toothpick is (per the README):




        • pure java

        • fast, it doesn't use reflection but annotation processing

        • simple, flexible, extensible & powerful, robust & tested

        • thread safe

        • documented & Open Source

        • scope safe : it enforces leak free apps

        • test oriented : it makes tests easier

        • it works very well with Android or any other context based framework (such as web containers)


        It can even be faster than Dagger 2 in most cases, and it's much simpler.



        Note: Yes, I am one of the authors.






        share|improve this answer
























        • Can we use Android annotation processor for Toothpick?

          – Yousha Aleayoub
          Jan 15 at 21:08
















        5














        You should give a try at Toothpick.



        Toothpick is (per the README):




        • pure java

        • fast, it doesn't use reflection but annotation processing

        • simple, flexible, extensible & powerful, robust & tested

        • thread safe

        • documented & Open Source

        • scope safe : it enforces leak free apps

        • test oriented : it makes tests easier

        • it works very well with Android or any other context based framework (such as web containers)


        It can even be faster than Dagger 2 in most cases, and it's much simpler.



        Note: Yes, I am one of the authors.






        share|improve this answer
























        • Can we use Android annotation processor for Toothpick?

          – Yousha Aleayoub
          Jan 15 at 21:08














        5












        5








        5







        You should give a try at Toothpick.



        Toothpick is (per the README):




        • pure java

        • fast, it doesn't use reflection but annotation processing

        • simple, flexible, extensible & powerful, robust & tested

        • thread safe

        • documented & Open Source

        • scope safe : it enforces leak free apps

        • test oriented : it makes tests easier

        • it works very well with Android or any other context based framework (such as web containers)


        It can even be faster than Dagger 2 in most cases, and it's much simpler.



        Note: Yes, I am one of the authors.






        share|improve this answer













        You should give a try at Toothpick.



        Toothpick is (per the README):




        • pure java

        • fast, it doesn't use reflection but annotation processing

        • simple, flexible, extensible & powerful, robust & tested

        • thread safe

        • documented & Open Source

        • scope safe : it enforces leak free apps

        • test oriented : it makes tests easier

        • it works very well with Android or any other context based framework (such as web containers)


        It can even be faster than Dagger 2 in most cases, and it's much simpler.



        Note: Yes, I am one of the authors.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 9 '16 at 6:17









        SnicolasSnicolas

        32.3k1192161




        32.3k1192161













        • Can we use Android annotation processor for Toothpick?

          – Yousha Aleayoub
          Jan 15 at 21:08



















        • Can we use Android annotation processor for Toothpick?

          – Yousha Aleayoub
          Jan 15 at 21:08

















        Can we use Android annotation processor for Toothpick?

        – Yousha Aleayoub
        Jan 15 at 21:08





        Can we use Android annotation processor for Toothpick?

        – Yousha Aleayoub
        Jan 15 at 21:08











        3














        Use Android Annotations or Butterknife to ease your coding. But don't go for Roboguice! Roboguice forces your activies, fragments to extend to roboguice classes. Not fun, at all!



        Dagger 2 is a much better option. You can use it along with Android Annotations if you'd like. I would just use Android Annotations for a simple app, but these days is good to work more with Dagger.






        share|improve this answer


























        • Whats the problem in extending from RoboActivity (that extends from Activity) while you can extend from Activity? you are not losing anything here.

          – vijay
          Oct 9 '17 at 17:55











        • It's an old library. It used to force you to use their Android component flavors. Now the best option is Dagger 2. Good luck.

          – Juan Mendez
          Nov 12 '18 at 23:55


















        3














        Use Android Annotations or Butterknife to ease your coding. But don't go for Roboguice! Roboguice forces your activies, fragments to extend to roboguice classes. Not fun, at all!



        Dagger 2 is a much better option. You can use it along with Android Annotations if you'd like. I would just use Android Annotations for a simple app, but these days is good to work more with Dagger.






        share|improve this answer


























        • Whats the problem in extending from RoboActivity (that extends from Activity) while you can extend from Activity? you are not losing anything here.

          – vijay
          Oct 9 '17 at 17:55











        • It's an old library. It used to force you to use their Android component flavors. Now the best option is Dagger 2. Good luck.

          – Juan Mendez
          Nov 12 '18 at 23:55
















        3












        3








        3







        Use Android Annotations or Butterknife to ease your coding. But don't go for Roboguice! Roboguice forces your activies, fragments to extend to roboguice classes. Not fun, at all!



        Dagger 2 is a much better option. You can use it along with Android Annotations if you'd like. I would just use Android Annotations for a simple app, but these days is good to work more with Dagger.






        share|improve this answer















        Use Android Annotations or Butterknife to ease your coding. But don't go for Roboguice! Roboguice forces your activies, fragments to extend to roboguice classes. Not fun, at all!



        Dagger 2 is a much better option. You can use it along with Android Annotations if you'd like. I would just use Android Annotations for a simple app, but these days is good to work more with Dagger.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 12 '18 at 23:56

























        answered Jul 4 '15 at 18:45









        Juan MendezJuan Mendez

        1,19511415




        1,19511415













        • Whats the problem in extending from RoboActivity (that extends from Activity) while you can extend from Activity? you are not losing anything here.

          – vijay
          Oct 9 '17 at 17:55











        • It's an old library. It used to force you to use their Android component flavors. Now the best option is Dagger 2. Good luck.

          – Juan Mendez
          Nov 12 '18 at 23:55





















        • Whats the problem in extending from RoboActivity (that extends from Activity) while you can extend from Activity? you are not losing anything here.

          – vijay
          Oct 9 '17 at 17:55











        • It's an old library. It used to force you to use their Android component flavors. Now the best option is Dagger 2. Good luck.

          – Juan Mendez
          Nov 12 '18 at 23:55



















        Whats the problem in extending from RoboActivity (that extends from Activity) while you can extend from Activity? you are not losing anything here.

        – vijay
        Oct 9 '17 at 17:55





        Whats the problem in extending from RoboActivity (that extends from Activity) while you can extend from Activity? you are not losing anything here.

        – vijay
        Oct 9 '17 at 17:55













        It's an old library. It used to force you to use their Android component flavors. Now the best option is Dagger 2. Good luck.

        – Juan Mendez
        Nov 12 '18 at 23:55







        It's an old library. It used to force you to use their Android component flavors. Now the best option is Dagger 2. Good luck.

        – Juan Mendez
        Nov 12 '18 at 23:55













        1














        Seems like Google chooses dagger, as they are developing it jointly with Square, who created it.



        Concerning Butterknife and Dagger themselves, there is the SO question difference-between-dagger-and-butterknife-android which clarifies how they complement each other.






        share|improve this answer






























          1














          Seems like Google chooses dagger, as they are developing it jointly with Square, who created it.



          Concerning Butterknife and Dagger themselves, there is the SO question difference-between-dagger-and-butterknife-android which clarifies how they complement each other.






          share|improve this answer




























            1












            1








            1







            Seems like Google chooses dagger, as they are developing it jointly with Square, who created it.



            Concerning Butterknife and Dagger themselves, there is the SO question difference-between-dagger-and-butterknife-android which clarifies how they complement each other.






            share|improve this answer















            Seems like Google chooses dagger, as they are developing it jointly with Square, who created it.



            Concerning Butterknife and Dagger themselves, there is the SO question difference-between-dagger-and-butterknife-android which clarifies how they complement each other.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 23 '17 at 11:47









            Community

            11




            11










            answered Jul 3 '15 at 10:53









            serv-incserv-inc

            13.8k56985




            13.8k56985























                1














                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.







                share|improve this answer




























                  1














                  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.







                  share|improve this answer


























                    1












                    1








                    1







                    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.







                    share|improve this answer













                    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.








                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 3 '15 at 10:56









                    serv-incserv-inc

                    13.8k56985




                    13.8k56985























                        1














                        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






                        share|improve this answer




























                          1














                          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






                          share|improve this answer


























                            1












                            1








                            1







                            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






                            share|improve this answer













                            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







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 28 '16 at 15:24









                            Pier BetosPier Betos

                            459213




                            459213























                                0














                                I think the better between (in terms of performance) ButterKnife and AndroidAnnotation is the second. ButterKnife uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time. Instead, AndroidAnnotations, process all annotations at compile time.






                                share|improve this answer



















                                • 4





                                  "ButterKnife inject code at runtime" - Are you sure?

                                  – naXa
                                  Jun 19 '15 at 6:42











                                • Read first para of this article thekeyconsultant.com/2013/09/…

                                  – Redman
                                  Apr 17 '17 at 6:58
















                                0














                                I think the better between (in terms of performance) ButterKnife and AndroidAnnotation is the second. ButterKnife uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time. Instead, AndroidAnnotations, process all annotations at compile time.






                                share|improve this answer



















                                • 4





                                  "ButterKnife inject code at runtime" - Are you sure?

                                  – naXa
                                  Jun 19 '15 at 6:42











                                • Read first para of this article thekeyconsultant.com/2013/09/…

                                  – Redman
                                  Apr 17 '17 at 6:58














                                0












                                0








                                0







                                I think the better between (in terms of performance) ButterKnife and AndroidAnnotation is the second. ButterKnife uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time. Instead, AndroidAnnotations, process all annotations at compile time.






                                share|improve this answer













                                I think the better between (in terms of performance) ButterKnife and AndroidAnnotation is the second. ButterKnife uses compile time Annotation (RetentionPolicy.CLASS), but it inject code at runtime, resulting greater effort of time. Instead, AndroidAnnotations, process all annotations at compile time.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Oct 7 '14 at 11:03









                                ech0s7rech0s7r

                                118114




                                118114








                                • 4





                                  "ButterKnife inject code at runtime" - Are you sure?

                                  – naXa
                                  Jun 19 '15 at 6:42











                                • Read first para of this article thekeyconsultant.com/2013/09/…

                                  – Redman
                                  Apr 17 '17 at 6:58














                                • 4





                                  "ButterKnife inject code at runtime" - Are you sure?

                                  – naXa
                                  Jun 19 '15 at 6:42











                                • Read first para of this article thekeyconsultant.com/2013/09/…

                                  – Redman
                                  Apr 17 '17 at 6:58








                                4




                                4





                                "ButterKnife inject code at runtime" - Are you sure?

                                – naXa
                                Jun 19 '15 at 6:42





                                "ButterKnife inject code at runtime" - Are you sure?

                                – naXa
                                Jun 19 '15 at 6:42













                                Read first para of this article thekeyconsultant.com/2013/09/…

                                – Redman
                                Apr 17 '17 at 6:58





                                Read first para of this article thekeyconsultant.com/2013/09/…

                                – Redman
                                Apr 17 '17 at 6:58


















                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f24351817%2fdagger-and-butter-knife-vs-android-annotations%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Full-time equivalent

                                Bicuculline

                                さくらももこ