It was in 2015 that Android plug-in technology really took off in China. At that time, the development of the business exposed two major problems of Android Native: first, the technical code volume expanded rapidly, and the module hot update had higher requirements; Second, the decoupling of functional modules and the separation of maintenance teams is the general trend.

Will RN replace plug-in?

The H5 and Hybird solve these problems, but never quite match native’s user experience. Therefore, pure native plug-in technology has been widely used in major manufacturers in China. But the argument is that RN is the best way to be truly dynamic, rather than plug-in. However, at least at present, plug-in technology has a market in China. For example, to make an APP for e-commerce or tourism, it is very frequent to use four components, and the four components must be plug-in. So the future of Android in China will be RN and plug-in.

[Plug-in technology analysis]

Plug-in technology sounds unfazed, but it really solves two problems: code loading and resource loading.

• Code loading

Classes can be loaded using Java’s ClassLoader mechanism, but for Android, classes are not ready to be loaded. Many components are “alive”. So for these flesh-and-blood classes, you have to breathe life into them, which is called component lifecycle management; There is also the issue of how to manage the classes loaded in. Assuming that multiple plug-ins depend on the same class, it is a ClassLoader management problem whether to extract common dependencies and manage them or whether plug-ins rely on them individually.

• Resource loading

Resource loading schemes are similar in principle, using the hidden method addAssetPath of AssetManager; But how are resources managed for different plug-ins? Is it a common set of resources or plug-in independent resources? How to avoid resource conflicts by sharing resources? For resource loading, some solutions share a set of resources and use the resource fragmentation mechanism to resolve conflicts (either modify AAPT or add compiled plug-ins). Some solutions choose independent resources, and different plug-ins manage their own resources.

[Plug-in open source project recommendation]

The following is a brief introduction of open source plug-in projects with many domestic applications:

▎ DroidPlugin


Github:github.com/DroidPlugin…

DroidPlugin is a plug-in framework implemented by 360 mobile phone assistant. It can directly run independent APK files of the third party without modification or installation of APK. A new plug-in mechanism, a setup free running mechanism, is a sandbox that is the foundation of modularity. DroidPlugin plugin mechanism: It can run APK files without installation or modification. This mechanism has certain benefits for improving the architecture of large APP and realizing multi-team collaborative development.

▎ Small


Github:github.com/wequick/Sma…

Introduction: Small is a lightweight cross-platform plug-in framework, based on the concept of “lightweight, transparent, minimal, cross-platform”.

▎ VirtualAPK


Github:github.com/didi/Virtua…

VirtualAPK is an open source plug-in framework for Didi, which supports almost all Android features and four components. VirtualAPK has no additional constraints on plug-ins, and native APK can be used as plug-ins. After the plug-in project is compiled and generated, the APK can be loaded through the host App. After each plug-in APK is loaded, a separate LoadedPlugin object will be created in the host. With these LoadedPlugin objects, VirtualAPK can manage plug-ins and give them new meaning, making them behave like apps installed on your phone.

▎ RePlugin


GitHub:github.com/Qihoo360/Re…

RePlugin is a complete, stable, and fully usable plug-in solution developed by The RePlugin Team at 360 Mobile Guard, and is the first in the industry to propose a “fully plug-in” solution (full features, full compatibility and full use). Nearly all 360’s apps, which have more than 100 million users, as well as several leading third-party apps, use RePlugin.

RePlugin features:

Number of inserts 103 (57 cores)

Plug-ins account for 83% of applications

Up to 596 editions are issued per year (2 times per day)

The collapse rate is one in 10,000 (0.01%), which is extremely low

It was applied in 2014 and verified in 3 years

▎ Android — the Plugin Framework


GitHub:github.com/limpoxe/And…

The Android-plugin-framework is an Android plug-in Framework, which is used to run the plug-in APK without installation through dynamic loading. Although the framework supports standalone plug-ins, the goal is not to support any three-party app, unlike parallel space or app dopes, for example. The framework’s approach is to hook on demand, providing support for system features and apis that are needed. This is sufficient for developing both independent and two-party plug-ins.

▎DL dynamically loads the framework


Github:github.com/singwhatiwa…

DL framework dynamic loading mainly solves two complex problems: resource access and activity lifecycle management. In addition, the DL framework does a good job of solving a lot of annoying little problems. One thing to note is that it is not possible to tune up any apK that is not installed, this is technically difficult to do, and the APK that we tune must be governed by some specification, and only the APK that is developed under this specification can we tune up.

▎ AndroidDynamicLoader


GitHub:github.com/mmin18/Andr…

Android dynamic loading framework, he is not using proxy Activity implementation but using Fragment and Schema implementation. You can download the demo:


▎ DynamicAPK


GitHub:github.com/CtripMobile…

Introduction: Implement Android App multi-APK plug-in and dynamic loading, support resource subcontracting and hot repair. Ctrip App plug-in and dynamic loading framework.

▎ ACDD


GitHub:github.com/bunnyblue/A…

Introduction: Non-agent Android dynamic deployment framework, the code follows MIT License, Activity, Receiver support stub mode, if there are bugs can be submitted in the issue. Gif demo animation (github.com/bunnyblue/A…


Android Senior Engineer Growth Plan series course “Hot Repair and Plug-in topics” limited to 20 discount slots, want to learn NDK and JNI basics

image.png