Hotfix, the most intuitive understanding is the Windows system we use. The Windows system will periodically release some patches, we install these patches, the system bug has been fixed. So, hotfix is an effective way to fix bugs. app product is different from web products, one of the app's mishap is unable to fix the bug in time, create the repair package--User Download new Package--installation, this process is not only complex, but also can not guarantee that the online version is the repair version, the bug will always exist. If hotfix can be implemented on the Android side, bug fixes will be less complex and will be able to converge on the app version. recently learned the idea of hot repair of QQ space, but also study on GitHub based on this idea of the implementation of the plan, then summarize this solution practice basis: 1.QQ spatial heat repair ideas http://bugly.qq.com/blog/?p=781 (Must read OH) 2.github Open source project dodola/hotfix https://github.com/dodola/HotFix (Baidu classmate realization) Jasonross/nuwa https://github.com/ jasonross/nuwa (for students) Scope of application: 4.0 to 6.0 of system versions have been tested for hot patching. The implementation of dodola is very simple, as demo is very good, able to understand the entire hotfix process. The realization of Nuwa is more perfect, it can be used directly by everyone. Then a string of ideas, the hotfix have an impression: 1. For bugs in the online apk, we can consider replacing the bug class with the fixed class by hotfix, which will work correctly. * * The Bug class needs to be fixed, fixed to the fixed class, and then the fixed class is considered for replacing the bug class. 2. To replace Bug.class with Fixed.class, it is necessary to classloader load Fixed.class instead of Bug.class * * by dynamically modifying ClassLoader in PathList, Put Fixed.class in front of Bug.class, ClassLoader load to Fixed.class will not continue to look for BUG.CLASS out. 3.apk Dex->odex in the installation phase will determine whether the class direct reference is within the current Dex, if the class_ispreverified tag. If this tag is marked, the class will only look for the class that is directly referenced in the current Dex and cannot achieve the effect of the substitution. * * To clear the class_ispreverified tag operation for the reference class of the replacement class, the procedure is to dynamically insert class from other Dex in the package stage class, with Javassist. Since then, we have made it clear that there are two issues that need to be addressed in hotfix: 1. Try to remove all classes from the class_ispreverified tag so that you can do the class substitution (performance or anything, which is optimized, and the bug crashes). So we're going to make a inject_dex that's dynamically injected into as many classes as possible. 2. We will pack the Fixed_dex and put the class that needs to be replaced inside. So the next step from the code of the process to see how to achieve: 1.A Project write a Bugclass.java, inside there is a method, return "bug". 2.B Project Write a class Antilazyload.java, does not contain any content, is used to let a project reference external class. Write a Hotfix.java in the 3.A project that contains the code to merge Dex and put other Dex in front of the a.dex. Application in 4.A Engineering calls hotfix to merge Dex, guaranteeing a.dex after other Dex. 5.A engineering is injected dynamically through javassist during the packaging phase, injecting anitilazyload.class into the class builder that needs to be replaced. (This step clears the class_ispreverified). 6. The antilazyload and the revised bugclass are packaged separately, Inject_dex and Fixed_dex. 7. Put into the assets for processing when the application is initialized. Fixed_dex are generally placed in the cloud, but from the cloud and assets to get, in fact, no difference, the demo will be used assets on it. Run, after consolidating Dex in application, the bug has actually been fixed. There are dexposed and andfix as well as other options for follow-up studies.
Android-hotfix (QQ space idea) analysis