preface
Hot fix is “patching”. When an app goes online, if a major bug is found, it needs to be repaired urgently. The usual approach is to fix the bugs, then repackage them and launch them again. This method is costly and inefficient.
Therefore, hot repair technology arises at the right moment. The general approach of hot repair technology is to take the initiative to check whether there is a patch package on the server when the application is started, download it and take effect at the next startup, so that urgent online bugs can be quickly solved.
Advantages of thermal repair
There is no need to repackage and release the installation package, users do not have to perceive the repair, and users do not need to download the latest application, saving user traffic. High success rate of repair, avoid business loss caused by online bugs, and minimize the loss rate.
Principle of thermal repair
The principle of hot repair is mainly class replacement. The replacement of classes involves the use of ClassLoader. There are PathClassLoader and DexClassLoader that can be used to dynamically load code in Android.
Since PathClassLoader can only be used to load classes with APK installed in Dalvik VM, DexClassLoader can load classes without APK or dex in Dalvik and ART VM. So hot fixes use DexClassLoader to load the classes in the patch pack.
We can use DexClassLoader to load our patch, use reflection to get dexElements from PathClassLoader, and dexElements from DexClassLoader, and merge the two (patch in front, original in back). The hot repair effect is achieved by reassigning dexElements in the PathClassLoader through reflection.
Real time repair
The replacement scheme has many restrictions, but it has good timeliness, easy loading and immediate effect. Replace the original method in the loaded class, based on the original class modification; Since it is based on the existing class, this scheme cannot add or subtract methods and fields from the class because that would break the structure of the class.
Cold start repair
Cold start repair is the synthesis of new dex file to replace the original dex file (dex file contains all the app code), its role is to breakthrough the limitation of hot replacement is unable to add class method, if the code changes, such as new methods in the existing classes, modify the so, and so on and so forth, can better achieve repair.
Commonly used thermal repair frames
Dexposed framework: Star 4.4K
Ali – Open source – real-time fix project address: github.com/alibaba/dex…
introduce
Dexposed is a work of Alibaba Mobile Taobao based on open source Xposed framework project, Dexposed is a powerful and non-invasive runtime AOP (aspect-oriented programming) framework for Android application development.
Dexposed’S AOP is completely non-invasive and does not require any annotation processor, weaver or bytecode rewriter. Integration is as simple as loading a small JNI library with a single line of code during the initialization phase of the application.
You can hook up not only your application code, but also the Android framework code running in your application process. This feature is very useful in Android development because our developers rely heavily on the fragmented old Android platform (SDK).
Together with dynamic class loading, a small piece of compiled Java AOP code can be loaded into a running application, effectively changing the behavior of the target application without a restart.
use
The last submission record of this framework was On October 21, 2015, and it has been stopped updating for a long time, so it is not recommended for use
AndFix framework :Star 6.9K
Ali – Open source – real-time fix project address: github.com/alibaba/And…
introduce
AndFix is a solution for fixing bugs online rather than redistributing Android Apps, distributed as an Android library.
AndFix supports Android versions from 2.3 to 7.0, ARM and X86 architectures, Dalvik and ART runtimes (32-bit and 64-bit).
The AndFix patch is compressed in.apatch format and is distributed from your own server to clients to fix your application bugs.
use
The last submission record of this framework was On December 26, 2016. It has been stopped updating for a long time, so it is not recommended to use it now
Alibaichuan HotFix framework:
Ali – can’t repair address: open source, real-time baichuan.taobao.com/product/hot…
introduce
Alibaichuan HotFix is alibaichuan’s all-platform App HotFix service solution, which is based on Alibaba’s pioneering HotPatch technology and provides the most fine-grained HotFix capability.
use
The framework was last updated on June 7, 2017. The Sophix has been fully upgraded to 3.0 and can be used for quick integration by referring to the access instructions in the official documentation
Qzone Super Patch Framework:
Qzone – not open source – cold start repair
introduce
Qzone super patch technology is based on the dex subcontract scheme, using the principle of multidex loading. The general process is: after fixing the BUG method, put it into a separate DEX file, and then insert it into the front of the dexElements array, and let the virtual machine load the fixed method.
QFix framework:
Hand Q team – Open source – Cold start fix
introduce
QFix is a new hot patch solution for Android launched by Hand Q team, which effectively avoids unexpected DEX in Dalvik without affecting App runtime performance (no need to plug to preverify). Besides, it is also a lightweight implementation: All you need to do is call a very simple method.
Robust frame: Star 4K
Meituan — Open source — real-time fix address: github.com/Meituan-Dia…
introduce
Robust is a hot update scheme developed by Meituan. It is a new framework developed based on the principle of Instant Run. Compared with Tinker, which can only restart the DexElements loading order, Robust realizes the real-time implementation of code modification (hot swap).
use
The framework was last updated on April 13, 2020, and detailed usage instructions can be found in the official documentation.
Nuwa framework:
Dianping — reference Qzone to achieve open source — cold start repair address: github.com/jasonross/N…
introduce
Nu Wa is a goddess in ancient Chinese mythology who is famous for repairing heavenly pillars.
With this Nuwa project, you also have the ability to fix your Android applications without having to publish a new APK to the Appstore.
use
The last update of this framework was on November 14, 2015, and it has been stopped for a long time, so it is not recommended to use it now
RocooFix framework: Star 1.6K Baidu Finance – Open source – Cold start fix address: github.com/dodola/Roco…
The last update of this framework was on June 26, 2016. It has been stopped for a long time, so it is not recommended to use it now
Aceso framework: Star 790
Beautiful Mushroom Street — open source — real-time fix address: github.com/meili/Aceso
introduce
Aceso is an Android HotFix developed by optimizing AOSP’s solution to fix online bugs without releasing a new APK.
use
The framework was last updated on January 31, 2018, and detailed usage instructions can be found in the official documentation.
Amigo framework: Star 1.4K
Ele. me — open source — cold start fix address: github.com/eleme/Amigo
introduce
Amigo is a patch library that fixes all problems for your Android applications.
use
The framework was last updated on August 21, 2017. Please refer to the official documentation for detailed usage instructions.
Tinker framework:
Wechat – Open source – Cold start fix
Address: github.com/Tencent/tin…
introduce
Tinker is a patch library for Android that supports dex, libraries and resource updates without having to reinstall APK.
use
The framework was last updated on April 19, 2021, and detailed usage instructions can be found in the official documentation.
Sophix framework:
Ali – Not open source (commercial fee) – Real-time fix + cold start fix
introduce
The core design concept of The Sophix is non-invasive.
Our packaging process does not intrude into apK’s build process. All we need is the old and new APK that has been generated, and we don’t care how the APK was generated — whether it was packaged by Android Studio, Eclipse, or a custom packaging process. We didn’t change any of the packaged components or insert any AOP code in the middle of the patch generation process, and we did our best to not add any code that exceeded the developers’ expectations to avoid annoying them with extra hot fixes.
In Sophix, the only two lines of code needed were to initialize and request a patch. We didn’t even change the entry Application class, giving developers maximum transparency and freedom. We even redeveloped the packaging tool to make the patch tool operation graphical, and this wySIWYG patch generation method is also exclusive to Alige Fix. As a result, the access cost of the Sophix is also the lowest of any solution currently on the market.
This concept of non-invasive thermal update is the core idea extracted from our in-depth thinking from the perspective of user use in the design process.
The user here, of course, refers to the vast developer. For developers, hotfixes should be a business-neutral SDK component that is invisible throughout the development process. Ideally, developers would bring in two APKs, one already installed on the phone and one to be released. We can generate patches according to these two APKs directly through the tool, and then send the patch to the old app that has been installed, so that the old app can be directly loaded and reborn into a new app. With the new app loaded with the patch pack, the functionality and usage of the new APP will be the same as installing the new APK directly.
As for the Sophix name, it comes from Sophic + FIX, a more sensible thermal FIX.
use
The framework for commercial use, each account can have free use of equipment 50,000.
Simple classification
Native hook:
RocooFix, AndFix, Ali Baichuan HotFix
Java:
Qzone Super patch, QFix, Robust, Nuwa, RocooFix, Aceso, Amigo, Tinker
Mixing:
Sophix
Reasonable classification
Native hook:
RocooFix, AndFix, Ali Baichuan HotFix
Java multidex:
Qzone Super patch, QFix, Nuwa, RocooFix
Java hook:
Robust, Aceso
Dex replacement:
Amigo, Tinker
Mixing:
Sophix