{"id":15131406,"url":"https://github.com/manbanggroup/phantom","last_synced_at":"2025-05-16T16:03:46.981Z","repository":{"id":55067829,"uuid":"153224042","full_name":"ManbangGroup/Phantom","owner":"ManbangGroup","description":"Phantom — 唯一零 Hook 稳定占坑类 Android 热更新插件化方案","archived":false,"fork":false,"pushed_at":"2019-07-19T06:26:28.000Z","size":469,"stargazers_count":1362,"open_issues_count":15,"forks_count":189,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-05-16T16:03:26.458Z","etag":null,"topics":["android","android-library","plugin","plugin-architecture","plugin-engine","plugin-sdk","plugin-system"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ManbangGroup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/security.md","support":null}},"created_at":"2018-10-16T04:46:06.000Z","updated_at":"2025-05-13T12:22:09.000Z","dependencies_parsed_at":"2022-08-14T11:00:30.967Z","dependency_job_id":null,"html_url":"https://github.com/ManbangGroup/Phantom","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManbangGroup%2FPhantom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManbangGroup%2FPhantom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManbangGroup%2FPhantom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ManbangGroup%2FPhantom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ManbangGroup","download_url":"https://codeload.github.com/ManbangGroup/Phantom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254564113,"owners_count":22092120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","plugin","plugin-architecture","plugin-engine","plugin-sdk","plugin-system"],"created_at":"2024-09-26T03:41:40.888Z","updated_at":"2025-05-16T16:03:46.947Z","avatar_url":"https://github.com/ManbangGroup.png","language":"Java","funding_links":[],"categories":["\u003ca id=\"2110ded2aa5637fa933cc674bc33bf21\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"fa49f65b8d3c71b36c6924ce51c2ca0c\"\u003e\u003c/a\u003eHotFix"],"readme":"[![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/ManbangGroup/Phantom/blob/master/LICENSE)\n[![Release Version](https://img.shields.io/badge/release-3.1.3-brightgreen.svg)](https://github.com/ManbangGroup/Phantom/releases)\n[![Build Status](https://travis-ci.com/ManbangGroup/Phantom.svg?branch=master)](https://travis-ci.com/ManbangGroup/Phantom)\n\n# Phantom — 唯一零 Hook 稳定占坑类 Android 热更新插件化方案\n\nPhantom 是满帮集团开源的一套稳定、灵活、兼容性好的 Android 插件化方案。\n\n## Phantom 的优势\n\n* 兼容性好：**零** Hook，兼容 Android 4.0 ~ Android Q beta 4(final APIs)\n* 功能完整：插件支持独立应用的绝大部分特性\n* 稳定可靠：历经货车帮旗下多款产品 50+ 插件两年多千万级用户验证（稳定性和兼容性指标都在 4 个 9 以上）\n* 部署灵活：宿主无需升级（无需在宿主 `AndroidManifest.xml` 中预埋组件），即可支持插件新增组件，甚至新增插件\n* 易于集成：无论插件端还是宿主端，只需『数行』就能完成接入，改造成本低\n\n## Phantom 与主流开源插件框架的对比\n\n| 特性 | [Atlas][1] | [Small][2] | [VirtualAPK][3] | [RePlugin][4] | [Phantom][5] |\n| ---- | ---- | ---- | ---- | ---- | ---- |\n| Hook 数量 | 较多 | 较少 | 较少 | 仅一处 | **零** |\n| 四大组件 | 全支持 | 只支持 `Activity` | 全支持 | 全支持 | 除 `ContentProvider` 外，全支持 |\n| 剔除公共库 | 支持 | 支持 | 支持 | 不支持 | 支持 |\n| 兼容性适配 | 高 | 高 | 高 | 高 | 非常高 |\n| 插件热更新 | 不支持 | 不支持 | 不支持 | 不支持 | 支持 |\n| 插件快速部署 | 不支持 | 不支持 | 不支持 | 支持 | 支持 |\n| 插件宿主通信 | 一般 | 一般 | 弱 | 一般 | 强 |\n\n## 接入指南\n\n### 宿主端\n\n#### 添加 Gradle 配置\n\n在宿主项目根目录下的 `build.gradle` 中增加宿主 gradle 依赖\n\n```groovy\nbuildscript {\n    dependencies {\n      classpath 'com.wlqq.phantom:phantom-host-gradle:3.1.2'\n    }\n}\n```\n\n在宿主工程 Application 模块的 `build.gradle` 中增加宿主 library 依赖，并应用宿主 gradle 依赖包含的 gradle 插件 `com.wlqq.phantom.host`\n\n```groovy\ndependencies {\n    compile 'com.wlqq.phantom:phantom-host-lib:3.1.3'\n}\n\napply plugin: 'com.wlqq.phantom.host'\n```\n\n#### 初始化 Phantom 插件框架\n\n在宿主工程 Application 模块中的 `Application#onCreate()` 方法中初始化 Phantom\n\n```java\npublic class YourApplication extends Application {\n    @Override\n    public void onCreate() {\n       super.onCreate();\n       PhantomCore.getInstance().init(this, new PhantomCore.Config());\n    }\n}\n```\n\n#### 安装内置到宿主 assets 中的插件 APK 并启动插件中的 Activity\n\n```java\n// 安装打包到宿主 assets 中 plugins 目录下的插件\nInstallResult ret = PhantomCore.getInstance().installPluginFromAssets(\"plugins/com.wlqq.phantom.pluign.component_1.0.0.apk\");\n// 插件安装成功后启动插件(执行插件的 Application#onCreate 方法)\nif (ret.isSuccess() \u0026\u0026 ret.plugin.start()) {\n    Intent intent = new Intent();\n    // 指定插件 Activity 所在的插件包名以及 Activity 类名\n    intent.setClassName(\"com.wlqq.phantom.pluign.component\", \"com.wlqq.phantom.pluign.component.MainActivity\");\n    PhantomCore.getInstance().startActivity(this, intent);\n}\n```\n\n### 插件端\n\n#### 添加 Gradle 配置\n\n在插件项目根目录下的 `build.gradle` 中增加插件 gradle 依赖\n\n```groovy\nbuildscript {\n    dependencies {\n      classpath 'com.wlqq.phantom:phantom-plugin-gradle:3.1.2'\n    }\n}\n```\n\n在插件项目 Application 模块的 `build.gradle` 中增加插件 library 依赖，并应用宿主 gradle 依赖包含的 gradle 插件 `com.wlqq.phantom.plugin`\n\n```groovy\nandroid {\n    buildTypes {\n        release {\n            minifyEnabled true\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n            // Phantom 混淆配置文件\n            proguardFile 'proguard-phantom.pro'\n        }\n    }\n}\n\ndependencies {\n    provided 'com.wlqq.phantom:phantom-plugin-lib:3.1.2'\n    compile 'com.android.support:support-v4:28.0.0'\n}\n\napply plugin: 'com.wlqq.phantom.plugin'\n\nphantomPluginConfig {\n    // BEGIN 剔除公共库配置\n    // 若插件中有使用 support-v4 ，则需要剔除掉(必须)\n    excludeLib \"com.android.support:support-v4:28.0.0\"\n    // END\n\n    // BEGIN 生成插件额外的混淆配置文件，避免因剔除公共库引起的混淆问题\n    libraryJarsProguardFile file('proguard-phantom.pro')\n    // END\n\n    // BEGIN 快速部署插件配置\n    // 宿主包名\n    hostApplicationId = \"com.wlqq.phantom.sample\"\n    // 宿主 launcher Activity full class name\n    hostAppLauncherActivity = \"com.wlqq.phantom.sample.MainActivity\"\n    // 插件包名\n    pluginApplicationId = android.defaultConfig.applicationId\n    // 插件版本名\n    pluginVersionName = android.defaultConfig.versionName\n    // END\n}\n```\n\n#### 在插件 `AndroidManifest.xml` 中申明对宿主 Phantom 插件框架最低版本依赖\n\n```xml\n\u003cmeta-data\n    android:name=\"phantom.service.import.PhantomVersionService\"\n    android:value=\"30000\"/\u003e\n```\n\n#### 编译插件\n\n与编译独立 APK 相同，如：\n\n* `./gradlew assembleDebug`\n* `./gradlew assembleRelease`\n\n#### 编译插件并将插件 APK 安装到宿主\n\n插件端使用的 Gradle 插件会自动为项目的 variant 生成相应的插件安装 task ，格式为 `phInstallPlugin${variant}` ，例如：\n\n* `./gradlew phInstallPluginDebug`\n* `./gradlew phInstallPluginRelease`\n\n## 进阶指南\n\n* [插件框架初始化](docs/phantom-core-init.md)\n* [插件管理](docs/plugin-management.md)\n* [四大组件](docs/components.md)\n* [Phantom 通信服务](docs/phantom-service.md)\n* [插件 meta-data](docs/android-manifest-metadata.md)\n* [Phantom 安全签名校验](docs/security.md)\n* [Native 支持](docs/native.md)\n* [已知问题](docs/known-issues.md)\n\n## 示例应用\n\n* [phantom-sample](phantom-sample)\n\n## 联系我们\n\n如果你在使用过程中遇到问题，或者有好的建议，欢迎给我们提 [issue](https://github.com/ManbangGroup/Phantom/issues) 或 [Pull Request](https://github.com/ManbangGroup/Phantom/pulls)。详细说明请移步 [贡献指南](CONTRIBUTING.md)\n\n临时交流 QQ 群号：**690051836**\n\n## 项目作者\n\n* 杨锋 - 核心开发者 - [iceskyblue](https://github.com/iceskyblue)\n* 邵彬 - 核心开发者 - [shaobin0604](https://github.com/shaobin0604)\n* 俞静波 - 主要贡献者 - [CalmYu](https://github.com/CalmYu)\n\n## 开源协议\n\nApache License 2.0, part MIT. See the [LICENSE](LICENSE) file for details.\n\n## 致谢\n\n参考以及使用的开源项目\n\n| 项目名称 | 开源协议 | 说明 |\n| ---- | ---- | ---- |\n| [Maven][6] | [Apache License](https://github.com/apache/maven/blob/master/LICENSE) | 依赖库版本比较 |\n| [jsemver][7] | [MIT License](https://github.com/zafarkhaja/jsemver/blob/master/LICENSE) | 依赖库版本比较 |\n| [Atlas][1] | [Apache License](https://github.com/alibaba/atlas/blob/master/LICENSE) | 首次加载插件提速 jar 包及 so 库 |\n| [RePlugin][4] | [Apache License](https://github.com/Qihoo360/RePlugin/blob/master/LICENSE) | Gradle Plugin 快速部署插件到宿主\u003cbr/\u003e反射工具类 ReflectUtils |\n| [VirtualApk][8] | [Apache License](https://github.com/didi/VirtualAPK/blob/master/LICENSE) | 构建 Gradle Plugin 对 Gradle 4.x + Android Gradle Plugin 3.x 的兼容处理 |\n\n[1]: https://github.com/alibaba/atlas \"Atlas\"\n[2]: https://github.com/wequick/Small \"Small\"\n[3]: https://github.com/didi/VirtualAPK \"VirtualAPK\"\n[4]: https://github.com/Qihoo360/RePlugin \"RePlugin\"\n[5]: https://github.com/ManbangGroup/Phantom \"Phantom\"\n[6]: https://github.com/apache/maven \"Maven\"\n[7]: https://github.com/zafarkhaja/jsemver \"jsemver\"\n[8]: https://github.com/didi/VirtualAPK \"VirtualAPK\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanbanggroup%2Fphantom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmanbanggroup%2Fphantom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmanbanggroup%2Fphantom/lists"}