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

应用程序重启后,补丁失效 #266

Open alexdyu opened 6 years ago

alexdyu commented 6 years ago

异常类型:app运行时异常

手机型号:Qiku V080

手机系统版本:Android 5.1

Robust版本:0.4.81

Gradle版本:2.1.0

系统:Window

问题描述: 在手机上运行sample程序打补丁,补丁工作正常。重启手机或者手动杀死正在运行的sample程序,然后重新运行sample程序,发现补丁效果消失,必须重新打补丁。

hedex commented 6 years ago

这个可以在application oncreate的时候调用一下哈,demo里面只是为了便于演示的哈

alexdyu commented 6 years ago

好的,但还有一个问题,由于补丁包很有可能是从网络获得的,而且大小不定,如果在app oncreate时进行这种耗时操作的话,很有可能会出现性能问题。 我看了一下打补丁的逻辑,能不能把打完补丁后删除本地临时文件的操作做成可配置的?以便在oncreate中从本地文件打补丁。多谢!

liufsd commented 6 years ago

确实,重启后就失效了的。在oncreate里面一直有调用初始化。是不是第一次修补完后,sdk内部删除了补丁文件?

wangxue commented 6 years ago

补丁加载是需要每次启动都主动加载的。 第一次修补后,sdk内部缺失删除了补丁文件,严格来说删除了tempPath,但是localPath还是在的。 具体加载过程跟踪PatchExecutor.run ,一共也就几十行代码。

liufsd commented 6 years ago

@wangxue 是的。👍。

alexdyu commented 6 years ago

问题已解决,多谢!


发件人: liupeng notifications@github.com 发送时间: 2018年7月6日 3:15:53 收件人: Meituan-Dianping/Robust 抄送: alexdyu; Author 主题: Re: [Meituan-Dianping/Robust] 应用程序重启后,补丁失效 (#266)

@wangxuehttps://github.com/wangxue 是的。👍。

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/Meituan-Dianping/Robust/issues/266#issuecomment-402913448, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGNKe0NawBQKMvA5UROam_7t-ptxdnAyks5uDtZpgaJpZM4TV-we.

kevinIn commented 6 years ago

@alexdyu 你是怎么解决的?能说一下么?

alexdyu commented 5 years ago

每次应用启动时,检查是否存在补丁文件,如果存在,主动加载补丁。将来考虑使用自定义classloader来完成这个动作,这样做还有一个好处就是每次只加载需要用的类,不必一次加载全部。


发件人: kevinIn notifications@github.com 发送时间: 2018年10月18日 7:42 收件人: Meituan-Dianping/Robust 抄送: alexdyu; Mention 主题: Re: [Meituan-Dianping/Robust] 应用程序重启后,补丁失效 (#266)

@alexdyuhttps://github.com/alexdyu 你是怎么解决的?能说一下么?

― You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/Meituan-Dianping/Robust/issues/266#issuecomment-430907873, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AGNKe4HwyLWjnMe0OXfA9KtlTfCW7aUkks5umDDegaJpZM4TV-we.

jorry commented 5 years ago

如果放到application有一个场景需要考虑,app进程没有被杀掉之前,这时候正好有补丁下发,app是无法初始化补丁的。 这里需要权衡一下