Android注解框架Dagger ,Butterknife 和AndroidAnnotations以及RoboGuice的比较

来源:互联网 发布:akg k309和y10 知乎 编辑:程序博客网 时间:2024/05/02 16:54

http://stackoverflow.com/questions/24351817/dagger-and-butter-knife-vs-android-annotations
这片文章的答案,简单的介绍了三种注解框架(Dagger,Butterknife以及AA)的异同以及简单的比较。

RoboGuice是Google官方的注解框架,不过每个类都需要继承RoboActivity。

下面进行客观的对比:

Github关注度:

(1)Roboguice https://github.com/roboguice/roboguice
roboguice

(2)Butterknife https://github.com/JakeWharton/butterknife
butterknife

(3)Dagger https://github.com/square/dagger
dagger

(4)AndroidAnnotations https://github.com/excilys/androidannotations
androidannotations

由此可见,AndroidAnnotations在国际的使用频率较前面的高。
那么,其他方面呢?

AndroidAnnotations的使用也较其他的注解框架好用。具体用过之后都可以知道,其次,不同于Butterknife,AA实在编译时执行生成代码,在运行应用时,对性能没有影响。
Butterknife会在应用运行时反射执行,可能会有一些性能方面的影响。

PS:通过分析其他的App,比如“英语流利说”使用的就是butterknife作为注解框架,同时使用Retrofit作为网络请求框架。
而其他的App也大部分使用butterknife作为注解框架,可能是用的比较多吧。具体使用的时候可以作为权衡来比较难易度而后选择一个适合自己的才是王道。

本文仅简单的比较一下,具体的使用及用法还请自行查阅相关资料。

1 0
原创粉丝点击