RePlugin Android Plug-in Framework

repository·dev·Indexed 27 days ago

https://github.com/qihoo360/replugin

A complete Android plug-in framework that enables adding new components and plug-ins to an application without updating the main app. It uses a ClassLoader hook for high stability (crash ratio ~0.01%) and supports Android API Level 9+. Key features include support for the four major Android components, static Receivers, Task-Affinity, Multi-Process, AppCompat, and DataBinding. The framework consists of the RePlugin Host Gradle plugin, Host Library, Plugin Gradle, and Plugin Library.

Tokens
3.7K
Snippets
2
Records
27
Agent score
92%

What's inside RePlugin

  1. Overview of RePlugin Android Plug-in Framework

    dev

    RePlugin is a flexible and stable Android plug-in solution designed for general use. It allows developers to add new components and plug-ins without upgrading the main application.

    Key features include:

    • Extreme Flexibility: Supports new plug-ins without main app upgrades.
    • High Stability: Uses only a ClassLoader hook (no Binder hook), resulting in a crash ratio as low as 0.01%.
    • Rich Feature Support: Seamlessly supports Activities, Services, Providers, static Receivers, Task-Affinity, Multi-Process, User-Defined Themes, AppCompat, DataBinding, and more.
    • Inter-process Communication: Supports Sync, Async, Binder, and cross-plug-in broadcasts.
    • Compatibility: Supports Android API Level 9 (Android 2.3) and above, including full support for Android 9.0 (P).
  2. Overview of RePlugin Framework

    dev

    RePlugin is a stable, flexible, and comprehensive Android plugin framework designed for 'full pluginization' (full feature support, full compatibility, and full usage). It is a 'hole-occupying' (占坑) solution, meaning it provides the necessary infrastructure within the host app to support plugins without requiring the host's AndroidManifest.xml to be updated for every new component or plugin.

    Key Advantages

    • Extreme Flexibility: Supports adding new components (including the four major Android components) and entirely new plugins without upgrading the host application.
    • High Stability: Uses only a single Hook point (ClassLoader) and avoids Binder Hooks, resulting in a very low crash rate (~0.01%) and excellent compatibility across various Android ROMs.
    • Rich Feature Support: Supports static Receivers, Task-Affinity, custom Themes, process holes, AppCompat, DataBinding, and SO libraries.
    • Easy Integration: Can be integrated into both host and plugin applications with only a few lines of code.
    • Mature Management: Includes a companion plugin management service for installation, upgrading, uninstallation, version management, IPC, and security verification.
  3. Use RePlugin Plugin Library to convert a project into a plugin

    dev

    The RePlugin Plugin Library is a Java library that must be imported by your Plugin project. It enables the plugin to interact with the main application (Host) by using Java reflection to call interfaces within the RePlugin Host Library. It also provides the capability for "bi-directional communication" between the host and the plugin.

    To transform a standalone Android project into a RePlugin plugin, you must add this library as a dependency. For detailed integration steps and implementation guides, refer to the official RePlugin Wiki.

  4. Plugin Categories in RePlugin

    dev

    RePlugin supports various types of plugins that developers can implement. Existing plugin categories include:

    • Display Plugins (展示插件): e.g., Homepages, health checks, information feeds.
    • Business Plugins (业务插件): e.g., Cleaning tools, harassment interception, floating windows.
    • Cooperative Plugins (合作插件): e.g., App locks, free WiFi, security desktops.
    • Background Plugins (后台插件): e.g., Push services, service management, Protobuf.
    • Base Plugins (基础插件): e.g., Security WebView, sharing, location services.
  5. Access RePlugin documentation and samples

    dev

    To get started with RePlugin, you can access the following resources (Note: most detailed guides are in Chinese):

    • Quick Start Guide: For first-time users.
    • Step-by-step Tutorial: For advanced usage and gameplay.
    • Sample Project: View the replugin-sample directory to see concrete implementation examples.
    • FAQ: For troubleshooting common issues.
  6. RePlugin Plugin Management Service

    dev

    The RePlugin Plugin Management Service is a companion service provided by the RePlugin team (in collaboration with 360 Web Platform Dept) to handle the lifecycle and distribution of plugins. It is accessible at https://dc.360.cn/.

    Key Capabilities

    • Version Management: Restricts combinations of APK package names, aliases, and version numbers to prevent incorrect distribution.
    • Statistics: Tracks and displays data for distribution volume, download volume, installation volume, and error rates.
    • Release Management: Supports 'Test Versions' (for internal, AB, or grayscale testing) and 'Online Versions' (for full production release) to ensure stability.
    • Distribution Control: Allows developers to customize distribution speed and target specific operators or device manufacturers.
    • Flexible Conditions: Supports simple distribution (by count or specific device) and complex custom conditions using a text-based or code-based editor.
  7. Configure Maven repository for RePlugin

    dev

    Due to the decommissioning of JCenter, RePlugin has migrated to a new Maven repository. To continue using RePlugin in your project, you must add the following repository URL to your build.gradle file:

    maven {url "http://maven.geelib.360.cn/nexus/repository/replugin/"}
  8. Integrate RePlugin Host Library into your Android application

    dev

    The RePlugin Host Library is the core Java project containing almost all code related to RePlugin. To implement RePlugin in your application, the Host Application (主程序) must include this library as a dependency.

    For detailed integration steps and implementation guides, refer to the official RePlugin Wiki.

  9. Get Started with RePlugin

    dev

    Depending on your needs, use the following resources to integrate RePlugin:

    • New Users: Follow the Quick Start Guide to understand the basics and initial setup.
    • Advanced Users: Refer to the Detailed Tutorial to explore advanced usage and complex scenarios.
    • Code Examples: View the RePlugin Sample Source Code to see a concrete implementation of the framework.
    • Troubleshooting: If you encounter issues during integration, consult the FAQ.
  10. Integrate RePlugin Plugin Gradle for dynamic compilation

    dev

    The RePlugin Plugin Gradle is a Gradle plugin used during the compilation phase to implement the 'dynamic compilation scheme'. It is responsible for dynamically modifying primary call code, such as redirecting Activity inheritance and Provider redirection to RePlugin.

    To implement RePlugin in your project, you must depend on this Gradle plugin. Developers can also customize operations by modifying its properties. For detailed integration steps and methods, refer to the official RePlugin WiKi.