Meituan-Dianping / Robust

Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without a reboot.
Apache License 2.0
4.42k stars 807 forks source link

AutoPatch gradle 插件声明顺序问题 #248

Open devLiuGit opened 6 years ago

devLiuGit commented 6 years ago

异常类型:编译异常

Robust版本:0.4.75

Gradle版本:2.14.1

系统:Mac

wiki 中明确指出 autoPatch gradle plugin 需要紧跟 Android application 插件具体是出于什么样的目的? 我的理解是, autoPatch 生成插件所需保存的文件 mapping.txt 是为了解决混淆问题, methodsMap 是保存方法插桩中 方法名与方法 id 的映射. 那生成 patch 时对所需修复的版本信息的获取途径除了上面的两个文件以外就只剩下此次 autoPatch plugin 执行之前的编译产物了.

wiki 中所说的对 lambda 表达式使用 RobustModify.modify(); 标注, 但是我们项目里使用 retroLambda 对 lambda 表达式进行支持, application 编译过程中关闭了 jack. 出现的现象就是在修复的方法中引入 lambda 表达式后, autoPatch 失败. 将 autoPatch plugin 移动到 retroLambda plugin 后面 autoPatch 成功.

那是不是说明, Robust 方法插桩应该在其他会插入代码的 gradle plugins 之后对方法体进行 if&else 的包围.

在所需要修复的方法中已经被其他 gradle plugins 插入过的代码, 在 autoPatch 时要保证生成的 patch 中仍然保留其他 plugins 插入的代码, 反而要将 autoPatch 放在所有 gradle plugins 之后. 在其他会插入代码的 gradle plugins 插入代码完成之后进行 autoPatch.

所以 autoPatch gradle plugins 应该是放在其他 gradle plugins 之后 ?

同理方法插桩 gradle plugin 的声明位置也应该放在其他 gradle plguins 之后?

hedex commented 6 years ago

是的哈