All Projects → ManbangGroup → Phantom

ManbangGroup / Phantom

Licence: apache-2.0
Phantom — 唯一零 Hook 稳定占坑类 Android 热更新插件化方案

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Phantom

Little Anti Cheat
Anti-Cheat for Source Games
Stars: ✭ 77 (-93.78%)
Mutual labels:  plugin
Splashpublishplugin
A Splash plugin for the Publish static site generator
Stars: ✭ 79 (-93.62%)
Mutual labels:  plugin
Betterdiscordapp
Better Discord App enhances Discord desktop app with new features.
Stars: ✭ 1,225 (-1.05%)
Mutual labels:  plugin
Kibananestedsupportplugin
A plugin for Kibana 5.5 and beyond that adds support for nested field search and aggregation.
Stars: ✭ 78 (-93.7%)
Mutual labels:  plugin
Comet Cache
An advanced WordPress® caching plugin inspired by simplicity.
Stars: ✭ 78 (-93.7%)
Mutual labels:  plugin
Pluginapplication
学习Android插件化必备demo
Stars: ✭ 79 (-93.62%)
Mutual labels:  plugin
Griefprevention
GriefDefender has replaced GP. See github link for latest information.
Stars: ✭ 76 (-93.86%)
Mutual labels:  plugin
Obs Gnome Screencast
GNOME Screen Cast OBS Studio plugin
Stars: ✭ 80 (-93.54%)
Mutual labels:  plugin
Xcactionbar
"Alfred for Xcode" plugin
Stars: ✭ 1,217 (-1.7%)
Mutual labels:  plugin
Craft Async Queue
Async Queue Handler for Craft 3
Stars: ✭ 80 (-93.54%)
Mutual labels:  plugin
Homebridge Weather
OpenWeatherMap Plugin for Homebridge
Stars: ✭ 78 (-93.7%)
Mutual labels:  plugin
Httpie Oauth
OAuth plugin for HTTPie
Stars: ✭ 78 (-93.7%)
Mutual labels:  plugin
Vue Rawmodel
RawModel.js plugin for Vue.js v2. Form validation has never been easier!
Stars: ✭ 79 (-93.62%)
Mutual labels:  plugin
Bgworker
Background Worker Processes for PostgreSQL written in Go
Stars: ✭ 77 (-93.78%)
Mutual labels:  plugin
Hidden Secrets Gradle Plugin
🔒 Deeply hide secrets on Android
Stars: ✭ 79 (-93.62%)
Mutual labels:  plugin
Vuex Multi Tab State
💾🔗🖥️ Share, synchronize and persist state between multiple tabs with this plugin for Vuex. TypeScript types included.
Stars: ✭ 77 (-93.78%)
Mutual labels:  plugin
Awesome Typescript Ecosystem
😎 A list of awesome TypeScript transformers, plugins, handbooks, etc
Stars: ✭ 79 (-93.62%)
Mutual labels:  plugin
Sentinl
Kibana Alert & Report App for Elasticsearch
Stars: ✭ 1,233 (-0.4%)
Mutual labels:  plugin
Tensorboard Empty Scalar Hider
Chrome Extension of hiding empty scalar/panes in TensorBoard.
Stars: ✭ 81 (-93.46%)
Mutual labels:  plugin
Xcodecolorsense
🎈 An Xcode plugin that makes working with color easier
Stars: ✭ 79 (-93.62%)
Mutual labels:  plugin

license Release Version Build Status

Phantom — 唯一零 Hook 稳定占坑类 Android 热更新插件化方案

Phantom 是满帮集团开源的一套稳定、灵活、兼容性好的 Android 插件化方案。

Phantom 的优势

  • 兼容性好: Hook,兼容 Android 4.0 ~ Android Q beta 4(final APIs)
  • 功能完整:插件支持独立应用的绝大部分特性
  • 稳定可靠:历经货车帮旗下多款产品 50+ 插件两年多千万级用户验证(稳定性和兼容性指标都在 4 个 9 以上)
  • 部署灵活:宿主无需升级(无需在宿主 AndroidManifest.xml 中预埋组件),即可支持插件新增组件,甚至新增插件
  • 易于集成:无论插件端还是宿主端,只需『数行』就能完成接入,改造成本低

Phantom 与主流开源插件框架的对比

特性 Atlas Small VirtualAPK RePlugin Phantom
Hook 数量 较多 较少 较少 仅一处
四大组件 全支持 只支持 Activity 全支持 全支持 ContentProvider 外,全支持
剔除公共库 支持 支持 支持 不支持 支持
兼容性适配 非常高
插件热更新 不支持 不支持 不支持 不支持 支持
插件快速部署 不支持 不支持 不支持 支持 支持
插件宿主通信 一般 一般 一般

接入指南

宿主端

添加 Gradle 配置

在宿主项目根目录下的 build.gradle 中增加宿主 gradle 依赖

buildscript {
    dependencies {
      classpath 'com.wlqq.phantom:phantom-host-gradle:3.1.2'
    }
}

在宿主工程 Application 模块的 build.gradle 中增加宿主 library 依赖,并应用宿主 gradle 依赖包含的 gradle 插件 com.wlqq.phantom.host

dependencies {
    compile 'com.wlqq.phantom:phantom-host-lib:3.1.3'
}

apply plugin: 'com.wlqq.phantom.host'

初始化 Phantom 插件框架

在宿主工程 Application 模块中的 Application#onCreate() 方法中初始化 Phantom

public class YourApplication extends Application {
    @Override
    public void onCreate() {
       super.onCreate();
       PhantomCore.getInstance().init(this, new PhantomCore.Config());
    }
}

安装内置到宿主 assets 中的插件 APK 并启动插件中的 Activity

// 安装打包到宿主 assets 中 plugins 目录下的插件
InstallResult ret = PhantomCore.getInstance().installPluginFromAssets("plugins/com.wlqq.phantom.pluign.component_1.0.0.apk");
// 插件安装成功后启动插件(执行插件的 Application#onCreate 方法)
if (ret.isSuccess() && ret.plugin.start()) {
    Intent intent = new Intent();
    // 指定插件 Activity 所在的插件包名以及 Activity 类名
    intent.setClassName("com.wlqq.phantom.pluign.component", "com.wlqq.phantom.pluign.component.MainActivity");
    PhantomCore.getInstance().startActivity(this, intent);
}

插件端

添加 Gradle 配置

在插件项目根目录下的 build.gradle 中增加插件 gradle 依赖

buildscript {
    dependencies {
      classpath 'com.wlqq.phantom:phantom-plugin-gradle:3.1.2'
    }
}

在插件项目 Application 模块的 build.gradle 中增加插件 library 依赖,并应用宿主 gradle 依赖包含的 gradle 插件 com.wlqq.phantom.plugin

android {
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            // Phantom 混淆配置文件
            proguardFile 'proguard-phantom.pro'
        }
    }
}

dependencies {
    provided 'com.wlqq.phantom:phantom-plugin-lib:3.1.2'
    compile 'com.android.support:support-v4:28.0.0'
}

apply plugin: 'com.wlqq.phantom.plugin'

phantomPluginConfig {
    // BEGIN 剔除公共库配置
    // 若插件中有使用 support-v4 ,则需要剔除掉(必须)
    excludeLib "com.android.support:support-v4:28.0.0"
    // END

    // BEGIN 生成插件额外的混淆配置文件,避免因剔除公共库引起的混淆问题
    libraryJarsProguardFile file('proguard-phantom.pro')
    // END

    // BEGIN 快速部署插件配置
    // 宿主包名
    hostApplicationId = "com.wlqq.phantom.sample"
    // 宿主 launcher Activity full class name
    hostAppLauncherActivity = "com.wlqq.phantom.sample.MainActivity"
    // 插件包名
    pluginApplicationId = android.defaultConfig.applicationId
    // 插件版本名
    pluginVersionName = android.defaultConfig.versionName
    // END
}

在插件 AndroidManifest.xml 中申明对宿主 Phantom 插件框架最低版本依赖

<meta-data
    android:name="phantom.service.import.PhantomVersionService"
    android:value="30000"/>

编译插件

与编译独立 APK 相同,如:

  • ./gradlew assembleDebug
  • ./gradlew assembleRelease

编译插件并将插件 APK 安装到宿主

插件端使用的 Gradle 插件会自动为项目的 variant 生成相应的插件安装 task ,格式为 phInstallPlugin${variant} ,例如:

  • ./gradlew phInstallPluginDebug
  • ./gradlew phInstallPluginRelease

进阶指南

示例应用

联系我们

如果你在使用过程中遇到问题,或者有好的建议,欢迎给我们提 issuePull Request。详细说明请移步 贡献指南

临时交流 QQ 群号:690051836

项目作者

开源协议

Apache License 2.0, part MIT. See the LICENSE file for details.

致谢

参考以及使用的开源项目

项目名称 开源协议 说明
Maven Apache License 依赖库版本比较
jsemver MIT License 依赖库版本比较
Atlas Apache License 首次加载插件提速 jar 包及 so 库
RePlugin Apache License Gradle Plugin 快速部署插件到宿主
反射工具类 ReflectUtils
VirtualApk Apache License 构建 Gradle Plugin 对 Gradle 4.x + Android Gradle Plugin 3.x 的兼容处理
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].