1 Star 0 Fork 70

yg178 / RePlugin

forked from replugin / RePlugin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

RePlugin Logo

license Release Version

RePlugin —— 历经三年多考验,数亿设备使用的,稳定占坑类插件化方案

RePlugin是一套完整的、稳定的、适合全面使用的,占坑类插件化方案,由360手机卫士的RePlugin Team研发,也是业内首个提出”全面插件化“(全面特性、全面兼容、全面使用)的方案。

其主要优势有:

  • 极其灵活:主程序无需升级(无需在Manifest中预埋组件),即可支持新增的四大组件,甚至全新的插件
  • 非常稳定:Hook点仅有一处(ClassLoader)。其崩溃率仅为“万分之一”,并完美兼容市面上近乎所有的Android ROM
  • 特性丰富:支持近乎所有在“单品”开发时的特性。包括静态Receiver、Task-Affinity坑位、自定义Theme、进程坑位、AppCompat、DataBinding等
  • 易于集成:无论插件还是主程序,只需“数行”就能完成接入
  • 管理成熟:拥有成熟稳定的“插件管理方案”,支持插件安装、升级、卸载、版本管理,甚至包括进程通讯、协议版本、安全校验等
  • 数亿支撑:有360手机卫士庞大的数亿用户做支撑,三年多的残酷验证,确保App用到的方案是最稳定、最适合使用的

截止2017年6月底,RePlugin的:

特性 描述
插件数 103(核心57个)
插件占应用比 高达83%
年发版次数 高达596次(工作日均2次)
崩溃率 万分之一(0.01%),极低
时间 2014年应用,3年验证

目前360公司几乎所有的亿级用户量的APP,以及多款主流第三方APP,都采用了RePlugin方案。

有关RePlugin的详细介绍,请点击这里阅读《RePlugin 官方 WiKi》

我们还支持以下特性

特性 描述
组件 四大组件(含静态Receiver)
升级无需改主程序Manifest 完美支持
Android特性 支持近乎所有(包括SO库等)
插件类型 支持自带插件(自识别)、外置插件
TaskAffinity & 多进程 支持(坑位方案
插件间耦合 支持Binder、Class Loader、资源等
进程间通讯 支持同步、异步、Binder、广播等
自定义Theme & AppComat 支持
DataBinding 支持
安全校验 支持
资源方案 独立资源 + Context传递(相对稳定)
Android 版本 API Level 9+ (2.3及以上)

愿景

让插件化能飞入寻常应用家,做到稳定、灵活、自由,大小项目兼用。

RePlugin 架构图

RePlugin Framework

以360手机卫士为例:

  • 系统层——Android:为Android Framework层。只有ClassLoader是Hook的,而AMS、Resources等都没有做Hook,确保了其稳定性。
  • 框架层——RePlugin框架:RePlugin框架层,只有RePlugin是对“上层完全公开”的,其余均为Internal,或“动态编译方案”生效后的调用,对开发者而言是“无需关心”的。
  • 插件层——各插件:“标蓝部分”是各插件,包括大部分的业务插件(如体检、清理、桌面插件等)。而其中“标黄部分”是支撑一个应用的各种基础插件,如WebView、Download、Share,甚至Protobuf都能成为基础插件。

使用方法

RePlugin的使用方法非常简单,大部分情况下和“单品”开发无异。

若您是第一次接触RePlugin,则请点击这里阅读《快速上手》,跟随我们的指引,了解更多的内容。

若您想了解更多有关RePlugin的玩法,则请点击这里阅读《详细教程》,了解更多好玩的玩法。

若您想看下RePlugin的Sample工程,进而了解框架的具体用法,则请点击这里查看Sample源代码

常见问题

以下针对在Issue中提到的“最常见问题”做出回答,希望能对您有帮助。

  • Q:您们和360之前发的DroidPlugin的主要区别是什么?
  • Q:插件与插件、主程序间可以共用资源吗?
  • Q:您们是否支持DataBinding?

Q:您们和360之前发的DroidPlugin的主要区别是什么?

A:这个问题问得很好。很多人都有这个疑惑——“为什么你们360要开发两套不同的插件化框架呢”?

其实归根结底,最根本的区别是——目标的不同

  • DroidPlugin主要解决的是各个独立功能拼装在一起,能够快速发布,其间不需要有任何的交互。目前市面上的一些双开应用,和DroidPlugin的思路有共同之处。当然了,要做到完整的双开,则仍需要大量的修改,如Native Hook等。

  • RePlugin解决的是各个功能模块能独立升级,又能需要和宿主、插件之间有一定交互和耦合。

此外,从技术层面上,其最核心的区别就一个:Hook点的多少

  • DroidPlugin可以做到让APK“直接运行在主程序”中,无需任何额外修改。但需要Hook大量的API(包括AMS、PackageManager等),在适配上需要做大量的工作。

  • RePlugin只Hook了ClassLoader,所以极为稳定,且同样支持绝大多数单品的特性,但需要插件做“少许修改”。好在作为插件开发者而言无需过于关心,因为通过“动态编译方案”,开发者可做到“无需开发者修改Java Code,即可运行在主程序中”的效果。

可以肯定的是,DroidPlugin也是一款业界公认的,优秀的免安装插件方案。我相信,随着时间的推移,RePlugin和DroidPlugin会分别在各自领域(全面插件化 & 应用免安装)打造出属于自己的一番天地。

Q:插件与插件、主程序间可以共用资源吗?

A:可以的,RePlugin会同时把Host和Plugin的Context传递给插件,供开发者选择。

补充:目前业内用得较多的,我们称之为“共享资源”方案——也即需要修改Aapt、做addAssetPath,以达到“宿主和插件用同一套资源”的效果。其好处是插件和主程序可以“直接使用”各自的资源,交互容易。但代价是需要做“资源分区”,以及针对不同机型(如ZTEResources、MiuiResources)等做适配,稳定性上值得考量

细心的朋友,可以看一下360手机卫士在2013年的APK,会发现一个小惊喜:其实,我们当年就是这个方案(彼时业内还没有相应公开方案)

而对于RePlugin而言,稳定永远是第一要义,因此我们采用的是“独立资源”方案,插件与应用间是完全独立的,每个插件都是一个Resources。

但是,“独立”不代表“不能共用”。想象一下,我们卫士有很多插件(如WebView等)都是需要将自己的资源(如Layout-XML等)共享给宿主和其它插件。这时候我们的做法是有两种:

  • 可以直接通过调用RePlugin.fetchResources接口,直接拿到资源
  • 通过反射获取View来间接拿到资源。

例如360手机助手所用的“换肤CommonView”就是采用第二种方式来做的,目前来看,没有问题。

Q:您们是否支持DataBinding?

A:支持。我们有几个插件在用。除此之外,我们的Sample工程,其Demo2就是用DataBinding做的,而Demo1是ButterKnife。您们可以体验一下。

已接入RePlugin的应用

我们诚挚期待您成为咱们RePlugin应用大家庭中的一员!

除了360集团旗下的亿级别应用以外,还有一些对稳定要求极其严苛的“金融类”产品,及第三方合作应用也接入了RePlugin(含SDK):

360 手机卫士 360 手机助手 360 手机浏览器 花椒相机 360 清理大师
360 影视大全 借钱吧 借了吗 海淘一号 华润通
360OS 应用 360借条 (即将公开) (即将公开) 你的App

这里衷心感谢 “360手机助手”,以及其它各App团队成员,帮助我们发现了很多需要改进的地方,并给予了非常积极的反馈。您们的鼓励与支持,让咱们的RePlugin能走的更远、更好!

已接入RePlugin的插件

目前已有的插件,可以分为以下几类,供各App开发者参考:

  • 展示插件:如卫士首页(是的,你没看错)、体检、信息流等
  • 业务插件:如清理、骚扰拦截、悬浮窗等
  • 合作插件:如程序锁、免费WiFi、安全桌面等
  • 后台插件:如Push、服务管理、Protobuf等
  • 基础插件:如安全WebView、分享、定位等

截止2017年6月底,这样的插件,我们有103个。衷心希望您能成为这个数字中的新的一员!

贡献自己的力量

我们欢迎任何形式的贡献,并致以诚挚的感谢!

你可以贡献代码、提出问题、编写文档等。有关“贡献”相关的内容,请点击这里阅读《贡献力量》

License

RePlugin is Apache v2.0 licensed.

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright (C) 2005-2017 Qihoo 360 Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

RePlugin - A flexible, stable, easy-to-use Android Plug-in Framework 展开 收起
Android
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Android
1
https://gitee.com/hwsyy/RePlugin.git
git@gitee.com:hwsyy/RePlugin.git
hwsyy
RePlugin
RePlugin
master

搜索帮助