快速开发Android应用

Android应用开发过程中,经常会遇到很多常见的类似问题,解决这些问题需要花时间,其实很多问题已经有了成熟的解决方案,比如很多第三方的开源lib,参考 Android LibrariesAndroid UI/UX Libraries

编码越少,Bug越少,效率自然会高。

但可能由于 根本没听说过、听说过但没用过、特殊原因不能用、自己已经有了解决方案等等原因,这些成熟的解决方案没能发挥作用,让开发人员踩了不少坑。可以Google一下“开发 坑” 或 “Dev Gotchas”看看其他人的经验分享。不要重复造轮子Don't Reinvent The Wheel! 但是不是所有“轮子”都适合你。这里介绍比较成熟的,普遍被应用的开源框架。


(1)依赖注入Dependency Injection
通用型
AndroidAnnotations – http://androidannotations.org/
View映射
Butter Knife – http://jakewharton.github.io/butterknife/
类注入
Dagger2 – http://google.github.io/dagger/

(2)网络通信Networking
异步请求
OKHttp – http://square.github.io/okhttp/
Volley – https://android.googlesource.com/platform/frameworks/volley/
REST客户端
Retrofit – http://square.github.io/retrofit/

(3)图像加载Image Loading
Picasso – http://square.github.io/picasso/
Fresco – http://frescolib.org/

(4)数据库DatabaseORM
OrmLite – http://ormlite.com/
GreenDAO – http://greendao-orm.com/

(5)组件通信EventBus
Otto – http://square.github.io/otto/
EventBus – https://github.com/greenrobot/EventBus

(6)模板代码Boilerplate Code
Hrisey – https://github.com/mg6maciej/hrisey

(7)工具Useful Tools
Genymotion Emulator – http://www.genymotion.com/
SQLite Browser – http://sqlitebrowser.org/
RestClient – https://github.com/wiztools/rest-client
Fluid UI – https://www.fluidui.com/demo/android-ics/
ProGuard – http://proguard.sourceforge.net/
LeakCanary – https://github.com/square/leakcanary
Stetho – http://facebook.github.io/stetho/
Realm –  https://realm.io/

方法总数限制65K
虚拟机Dalvik在执行DEX格式的Java应用程序时,使用原生类型short来索引DEX文件中的方法。这意味着单个DEX文件可被引用的方法总数被限制为65536。
引用
Unable to execute dex: method ID not in [0, 0xffff]: 65536
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536

可以将一个DEX文件分拆成多个DEX文件解决,参考 官网说明,需要特殊处理。开源项目 dex-method-counts可以用于统计APK中每个包的方法数量。避免使用Google Guava这样的类库,它一个就包含了14k方法。

慎重选型后,最多选择2到3个开源框架用于一个项目中。

参考:
http://www.codeproject.com/Articles/1004611/Open-source-Android-libraries-every-programmer-sho
http://www.technotalkative.com/lazy-productive-android-developer-1/

猜你喜欢

转载自rensanning.iteye.com/blog/2225267