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

热更新方法的返回值类型不匹配 .VerifyError: Verifier rejected #314

Open dsyaode opened 5 years ago

dsyaode commented 5 years ago

热更新补丁加载的时候失败了,报的错误: W/System.err: java.lang.VerifyError: Verifier rejected class PatchManipulateImp.TemplateViewManagerPatch: android.widget.TextView PatchManipulateImp.TemplateViewManagerPatch.createAndGetOriginalTextView() failed to verify: android.widget.TextView PatchManipulateImp.TemplateViewManagerPatch.createAndGetOriginalTextView(): [0x5D9] returning 'Reference: java.lang.Object', but expected from declaration 'Reference: android.widget.TextView' (declaration of 'PatchManipulateImp.TemplateViewManagerPatch' appears in patch2.10.0_38.jar_temp.jar)

查看补丁文件代码: 发现生成的 TemplateViewManagerPatch.createAndGetOriginalTextView 方法返回类型为TextView但是方法内却返回Object类型的对象

实际部分补丁代码: private TextView createAndGetOriginalTextView(View paramView, JsonCardViewHolder paramJsonCardViewHolder, MessageData paramMessageData) { Object localObject1; Context localContext; label57: Object localObject2; label159: int i; label223: Object localObject3; label291: label307: label473: Object localObject4; ... return localObject4; //此处为什么会返回Object类型的对象,而不是函数定义的TextView?

jjlan commented 5 years ago

我也遇到了这个问题,解决办法可以查看我的博客:https://www.jianshu.com/p/dae91cf497a3