The introduction

In the last stage, we learned the basic knowledge of Gradle and used two practical examples to reinforce the knowledge we have learned. (PS: Review here >>)

In front of the preparation, more is for the back of our actual android plug-in or hot repair to do the basic reserve, because in the plug-in/hot repair project, need through gradle basis to programming, such as: through gradle plug-in generation;

Next, we will gradually enter the field of plug-in/hot repair, in this stage we defined as “plug-in & hot repair series”, this is also one of the important foundation, because it involves more android application knowledge, the underlying knowledge;

After we finished learning “plug-ins & Hot repair series”, combined with the gradle technical knowledge we learned in the previous stage, plug-ins/hot repair and so on will be familiar with the project

The profile

In this chapter, we will learn about the past and present life of plug-in & hot repair, which is the historical development process, haha

Milestone 1

AndroidDynamicLoader

(1) Birth background: On July 27, 2012, Tu Yimin (Github named MMIN18) of Dianping released the first Android plug-in open source project AndroidDynamicLoader

(2) Mechanism, a plug-in framework based on Fragment, dynamically loading Fragement in the plug-in to achieve page switching

(3) The addAssetPath method of AssetManger is called by reflection

(4) Github address, github.com/mmin18/Andr… PS: This is an Ant build, because in 2012 AS didn’t come out, it was Eclipse

23Code

(1) Birth background: 23Code appeared in 2013

(2) Mechanism. 23Code provides a shell in which plug-ins can be dynamically downloaded and run;

(3) Other, 23Code is a custom UI control collection application, directly download a custom control demo, and run it; Project author and open source address is not found at present, find friends hard to share next ~

Atlas

(1) Birth background: Atlas plug-in framework of Taobao came out on March 27, 2013

(2) Mechanism, through reflection and lightweight hook scheme to realize module componentization, so as to reduce adaptation cost; At the same time, a lot of work is put into compile time to improve stability; Such as: ActivityThread that several classes of Hook, incremental update, degradation, compatibility and other technologies

(3) Pain points solved:

A) Container thinking to solve the problem of large-scale team collaboration; For example, in business development, each business can be independently compiled, debugged and run in the development stage, and finally integrated into the client in the form of a component. The parallel development of each business does not affect each other

B) Realize parallel development, rapid iteration and dynamic deployment, suitable for large and small App development of Android 4.x and above.

C) Online repair, with the ability of client dynamic release and quick repair

(4) Github, github.com/alibaba/atl…

(5) the official tutorials, edu.aliyun.com/course/68/l…

Second milestone

dynamic-load-apk

(1) Birth background: On March 30, 2014, Ren Yugang’s Android plug-in project Dynamic-load-APK was born. At the beginning, only the Activity plug-in was realized. Later, with the participation of Tian Xiao and Song Siyu, Service plug-in was realized

(2) Mechanism, from the App application layer to solve the problem, by creating a ProxyActivity class distributed by it, start the corresponding plug-in Activity; These schemes are collectively called “static proxy schemes”

(3) Actual combat, has withstood the test of ten million daily live App (such as: Tuniu App)

(4) Github: github.com/singwhatiwa…

CJFrameForAndroid

(1) Birth background: CJ Framework for Android by Zhang Tao was born in May 2014

(2) Mechanism, similar to dynamic-load-APk solution, both adopt static proxy solution, and also support the LaunchMode solution of the Activity

(3) Note that this framework is no longer updated

(4) Author, blog.kymjs.com/

(5) the blog, www.daimajiaoliu.com/daima/4717e…

android-pluginmgr

(1) Birth background: Houkx released the android-PluginMgr plug-in project in November 2014

(2) Mechanism, the earliest proposed in the AndroidManifest file to register a StubActivity to “cheat AMS”, actually open the ActivityA plug-in, but there is a short board, is not suitable for plug-in, to learn the idea mainly, ha ha ~

(3) Github: github.com/houkx/andro…

(4) Special meaning. From the “dynamic-Load-APK” thinking above, to the cheating AMS thinking here, to the hook directly cheating AMS in the back, it is actually an excessive thought

(5) the case of actual combat, in the game industry SDK, specific see: segmentfault.com/a/119000001… So this is kind of like the idea that we use now, maybe this is a collision of ideas

TurboDex

(1) Birth background, high school Lody releases TurboDex framework

(2) Mechanism, combining the “static proxy idea” and the “spoofing AMS” idea of pluginMgr framework

(3) Features: Good performance in fast loading DEX

(4) Github: github.com/asLody/Turb…

Android-Plugin-Framework

(1) Birth background: In May 2015, Limpoxe released the plug-in Framework Android-plugin-Framework

(2) Mechanism, on-demand hook, that is, to provide support for which system features and apis are needed

(3) Features, free of installation and running plug-in APK, support independent plug-in and non-independent plug-in

(4) Github: github.com/limpoxe/And…

Milestone 3

DroidPlugin

(1) Birth Background: On August 27, 2015, Zhang Yong’s DroidPlugin was released (360 team)

(2) Mechanism, Hook a lot of underlying code of Android system

(3) Features that can load any App into the host; You can write a host App based on this framework, and then load other people’s apps as plug-ins;

(4) Advantages:

(a) The host is completely isolated from the plug-in, the plug-in does not depend on the host, and can be installed and run independently. (b) low intrusion design, plug-ins do not need to inherit any classes. (c) Plug-in APK is the same as ordinary APK, so there is no threshold for plug-in development. Integration into a new project requires only three or two steps (e) Complete resource isolation between plug-ins and hosts without resource hopping (f) API low invasions: few apis. The HOST application needs only one line of code to integrate with the Droid Plugin (G) super isolation: complete code-level isolation between plug-ins and between plug-ins and hosts, without calling each other's code. Communication can only use the Android system level communication method.Copy the code

(5) Disadvantages:

(a) The plug-in is slow to start; (b) it lacks Hook for Native layer and is not well supported for some APK with Native code, so it may not run; (c) It cannot register some four components with special Intent Filter in the plug-in; (d) The main problem is the adaptation of the modelCopy the code

(6) GitHub: github.com/DroidPlugin…

(7) Birth background link: www.infoq.cn/article/201…

Weishu. Me/Archives /

OpenAtlas

(1) Birth background: OpenAtlas project came out in 2015 (later renamed ACDD); After studying the mobile shopping client, BunnyBlue found that part of Atlas was not completely confused, and then developed OpenAtlas on this basis.

(2) Mechanism (the same as Atlas), through reflection and lightweight hook scheme to realize module componentization, so as to reduce adaptation cost; At the same time, a lot of work is put into compile time to improve stability; Such as: ActivityThread that several classes of Hook, incremental update, degradation, compatibility and other technologies

(3) Features: By modifying and regenerating aAPT command, the resource ID of plug-in APK is no longer fixed 0x7f, but can be changed to 0x71; Resolved resource ID conflicts after merging plug-in resources into host HostApp resources

(4) the blog series analysis: blog. Imallen. Wang/archives/pa…

(5) Github: github.com/HiWong/Open…

DynamicAPK

(1) Birth background: DynamicAPK, a plug-in framework of Ctrip, was born in October 2015; Based on the OpenAltas framework, it integrates Ctrip’s own special business logic (for this reason, there are friends on the Internet that Ctrip plagiarism storm 😂)

(2) Mechanism and features, see the OpenAltas module above

(3) Birth background (if it is plug-in mode, it has the following benefits) :

(a) With business development, the original Ctrip wireless App development team is divided into multiple development teams including basic framework, hotel, air ticket and train ticket, etc. (b) Efficient cooperation mode: In this mode, the development of communication costs greatly increased, the previous collaboration model is difficult to continue (c) speed up the compilation, the project has been split into ten sub-projects, Android Studio compilation process of the shortcomings have been rapidly amplified, in Win7 mechanical hard disk development machine compilation time has broken through 1 hour, (d) The startup speed is accelerated. MultiDex provided by Google will perform all dex decompression, dexopt and loading operations in the main thread. This is a very long process, and users will obviously see a long black screen, which is more likely to cause ANR of the main thread. (e) Product A/B Testing, independently develop AB version of the module, rather than write AB version code in the same module. (f) Optional modules can be downloaded on demand. For example, modules used for debugging functions can be downloaded and loaded when necessary to reduce the Size of AppCopy the code

(4) Official blog: mp.weixin.qq.com/s?__biz=MzA…

(5) Github: github.com/CtripMobile…

Small frame

(1) Birth background: The Small framework of Bright GG was released at the end of December 2015;

(2) Vision: The world is so big, but the components are so small. Small, do the most lightweight cross-platform plug-in framework

(3) Idea: componentization: APP is divided into different functional modules to form independent components for the host to call

(4) Application scenario: it is suitable for splitting an APK into multiple public library plug-ins and business module plug-ins

(5) mechanism, through Hook Instrumentation to start the plug-in Activity, similar to DroidPlugin

(6) Data comparison:

(7) series source code parsing: ivonhoe. Making. IO / 2018/01/18 /…

(8) Github: github.com/wequick/Sma…

The focus of these frameworks

Based on the history above, we can see that these open source frameworks focus on the following:

(1) Compatibility of plug-ins, including the impact of Android system upgrade on plug-in framework, and the impact of different mobile ROM on plug-in.

(2) Stability of plug-ins, such as various bizarre crashes.

(3) Management of plug-ins, including installation and uninstallation.

Common uses of plug-in technology

(1) In the game industry, plug-in framework is more suitable for the game field. For example, king of Glory often has a new skin, or every few days to release a new hero, adjust the hero data, these do not need to re-issue.

(2) Data-driven products, ABTest. When the product manager is having A hard time deciding between two styles of design, make the two strategies into two plug-in packages and have 50% of users download Strategy A and the other 50% download strategy B and look at the data A week later

(3) Online problems, users can enjoy the new version of the plug-in in minutes without re-downloading the App

(4) To seize the market, the faster the new functions are released, the higher the market share and user share; Because releasing a new version to every Android market every once in a while can be annoying to users; The fixed release cycle of half a month can lead to a long backlog of new features that will be available to users after half a month, when competitors are already using the same new features.

(5) Other technical improvements, such as multi-module plug-in development/accelerating compilation speed

At the end

Haha, that’s all for this article (systematic learning and growing together)