一.组件化需解决的问题
1、组件之间 - 通信问题
数据通信 - 接口下沉
界面 - Arouter
事件 - EventBus
2、组件单独运行 - Application 和 module 切换
gradle自定义插件读取配置文件信息 -> 根据配置信息动态反射加载不同模式的Application实现Application和module的切换。
3、 组件之间- 资源冲突问题
定义弱约束
4、中间层臃肿
微信.api方案 https://mp.weixin.qq.com/s/6Q818XA5FaHd7jJMFBG60w
5、组件化后编译速度变慢
搭建私有maven 或 arr
加快编译速度 https://blog.csdn.net/walkeryudev/article/details/80360422
二.业内方案种类
1.CC
号称业界首个支持渐进式组件化改造的Android组件化开源框架。无论页面跳转还是组件间调用,都采用CC统一的组件调用方式完成。
https://github.com/luckybilly/CC
2.DD
https://github.com/luojilab/DDComponentForAndroid
得到的方案采用路由 + 接口下沉的方式,所有接口下沉到base中,组件中实现接口并在IApplicationLike中添加代码注册到Router中。
https://github.com/mqzhangw/JIMU
3.美团猫眼
https://blog.csdn.net/qq_22744433/article/details/77948442
美团零售
数据通信(ServiceLoader) + 页面路由(WMRouter) + 消息总线(LiveDataBus 组件化改装modular-event)
https://mp.weixin.qq.com/s/5A2zHOMAzFsGPaVPY0SRUw
4.谷歌(MVVM架构,基于dataBinding、lifecycle、retrofit2、rxjava2、okhttp、fresco。)
https://github.com/Dawish/GoogleArchitectureDemo
5.无需接口下沉
https://github.com/YummyLau/ComponentCornerstone
组件化方案优缺点
https://juejin.im/post/5a7ab8846fb9a0634514a2f5
https://github.com/luckybilly/AndroidComponentizeLibs