最近美团点评开源了其基于Instant Run 的热修复方案Robust,并且官方公布了修复率达99.9%成功率,听起来蛮诱人的。当然,市面上还有其他两种热修复方案:
- 基于multidex的热更新方案,如企鹅的Tinker
- 基于native hook方案,如猫厂的AndFix
只能说各有优劣吧。Robust是为每个函数都插入了一段逻辑,会增加app的体积,但是兼容性好些。原理篇,美团点评之前就有介绍:
http://www.tuicool.com/articles/JjaaayV
Robust的github地址:
https://github.com/Meituan-Dianping/Robust
注意:现在最新版本是0.3.2。0.3.0版本时,只支持Linux和Mac系统!0.3.1及之后的版本是支持Windows的,看文档很重要!
首先,吐槽下美团点评的文档写的确实不够详细,demo整理的有些乱。不过从issue中总能得到答案。接入的过程及过程中遇到了一些坑,现在记录下,也是学习的过程:
1.在App的build.gradle,加入依赖
apply plugin: 'com.android.application'
//制作补丁时将这个打开,auto-patch-plugin紧跟着com.android.application
//apply plugin: 'auto-patch-plugin'
apply plugin: 'robust'
dependencies{
compile 'com.meituan.robust:robust:0.3.2'
}
2在整个项目的build.gradle加入classpath
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.meituan.robust:g