Thursday, April 28, 2016

Android 热修复技术

遇到的问题:

为什么只需要将:
adb push app/build/outputs/nuwa/debug/patch.jar /sdcard/

为什么只需要将patch.jar 发布到 sdcard
重新启动app,Bug Fix。   重启的时候,是如何加载的呢?不知道为什么。谁可以为我解答!?

经验点:

1、生成patch,jar,也就是把修改的地方打包成patch.jar(这里的jar不是普通的jar,而是dex的jar);

2、将patch.jar的dex文件放在其他的分dex文件之前。

不错的链接:
https://github.com/supengchao/NuwaDemo/issues/1






Android 是如Compile
http://www.infoq.com/cn/articles/ctrip-android-dynamic-loading





技术点:


HotFix
https://zhuanlan.zhihu.com/p/20308548

DemO;
How to use Nuwa implement Hotfix?
http://www.jianshu.com/p/72c17fb76f21
Demo:
https://github.com/archmages/HotFixSamples




热修复:
http://mp.weixin.qq.com/s?__biz=MzI1MTA1MzM2Nw==&mid=400118620&idx=1&sn=b4fdd5055731290eef12ad0d17f39d4a&scene=0#wechat_redirect


android dex分包方案
https://m.oschina.net/blog/308583
简单的概括一下,就是把多个dex文件塞入到app的classloader之中,但是android dex拆包方案中的类是没有重复的,如果classes.dex和classes1.dex中有重复的类
multidex方案实现。然后在插入数组的时候,把补丁包插入到最前面去。

 we realized that we could work around this problem by breaking our app into multiple dex files, using the technique described here 
http://android-developers.blogspot.com/2011/07/custom-class-loading-in-dalvik.html
It catch me that:  The Dalvik VM provides facilities for developers to perform custom class loading. Instead of loading Dalvik executable (“dex”) files from the default location, an application can load them from alternative locations such as internal storage or over the network.




Build system:
Apk how to create , You can see this link, I think you just see the image  you can
see it.
http://developer.android.com/sdk/installing/studio-build.html






热修复原理介绍:
http://mp.weixin.qq.com/s?__biz=MzI1MTA1MzM2Nw==&mid=400118620&idx=1&sn=b4fdd5055731290eef12ad0d17f39d4a&scene=0#wechat_redirect








Nuwa:



感谢:

    刘强 昨天,他跟我提到 热修复技术。我之前从来没有听说到的技术,感觉非常的牛逼,不过,其实 真的是很牛逼!


    JasonRoss
    github:   https://github.com/jasonross


No comments:

Post a Comment