快速开发Android应用

本文介绍了Android开发中常用的成熟开源框架,包括依赖注入、网络通信、图像加载等,旨在提高开发效率并减少常见问题。
Android应用开发过程中,经常会遇到很多常见的类似问题,解决这些问题需要花时间,其实很多问题已经有了成熟的解决方案,比如很多第三方的开源lib,参考[url=https://github.com/wasabeef/awesome-android-libraries]Android Libraries[/url] 和 [url=https://github.com/wasabeef/awesome-android-ui]Android UI/UX Libraries[/url]。

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

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


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

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

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

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

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

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

[b](7)工具Useful Tools[/b]
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/

[color=red][b]方法总数限制65K[/b][/color]
虚拟机Dalvik在执行DEX格式的Java应用程序时,使用原生类型short来索引DEX文件中的方法。这意味着单个DEX文件可被引用的方法总数被限制为65536。
[quote]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[/quote]
可以将一个DEX文件分拆成多个DEX文件解决,参考[url=http://developer.android.com/tools/building/multidex.html]官网说明[/url],需要特殊处理。开源项目[url=https://github.com/mihaip/dex-method-counts]dex-method-counts[/url]可以用于统计APK中每个包的方法数量。避免使用Google Guava这样的类库,它一个就包含了14k方法。

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

参考:
[url=http://www.codeproject.com/Articles/1004611/Open-source-Android-libraries-every-programmer-sho]http://www.codeproject.com/Articles/1004611/Open-source-Android-libraries-every-programmer-sho[/url]
[url=http://www.technotalkative.com/lazy-productive-android-developer-1/]http://www.technotalkative.com/lazy-productive-android-developer-1/[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值