Amigo平台 (Amigo后端管理服务上线啦 :v:)
一个Android 平台的hotfix 库, 支持热更新,支持热修复
在project 的build.gradle 中
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.ele:amigo:0.6.2'
}
}
在module 的build.gradle 中
apply plugin: 'me.ele.amigo'
android {
...
}
//开发过程中你可以不想开启Amigo,可以把这个值设置为true
//你可以把这个定义在mybuild.gradle,以区分debug & release打包
amigo {
disable false //默认 false
}
就这样轻松的集成了Amigo。
2.1 to Nougat 7.1在热修复的过程中会进行一些耗时(dex优化)的操作,这些操作会在一个新的进程中的Activity 中执行,所以你可以在Manifest文件中增加下面的两个配置来自定义这个Activity,美化loading界面。
<meta-data
android:name="amigo_layout"
android:value="{your-layout-name}" />
<meta-data
android:name="amigo_theme"
android:value="{your-theme-name}" />
<meta-data
android:name="amigo_orientation"
android:value="{your-custom-orientation}"/>
提示:
meta-data信息请写在你自己的app module下的AndroidManifest.xml补丁包生效方式有两种可以选择:
稍后生效
如果不想立即生效而是用户第二次打开App 时才打入补丁包,可以通过这个方法:
java
Amigo.workLater(context, apkFile, callback);
立即生效
如果想要补丁包立即生效,调用以下方法,App 会立即重启,并且打入补丁包:
java
Amigo.work(context, apkFile);
Amigo.clear(context);
提示: 将App下次启动时删除所有的patch文件.
执行命令 ./gradlew runHost preparePatch 到Demo页面查看.
Gradle插件的代码在buildSrc目录下,这样每次编译项目时都会使用最新的插件代码。
Gradle插件会自动选择正确的库版本,在开发过程中,我们会使用amigo-lib这个模块,从而无需每次推送到maven仓库。
我们在app/build.gradle提供了两个gradle task: :app:runHost, :app:preparePatch, 可以有效的帮助加快开发.
./gradlew runHost, 编译并启动宿主app./gradlew preparePatch, 编译patch apk并推到设备sdcard中patch包中新增provider
修改声明方式,authorities须以"${youPackageName}.provider"开头
xml
<provider
android:name="me.ele.demo.provider.StudentProvider"
android:authorities="${youPackageName}.provider.student" />
修改调用方式
java
// 1. app进程内使用时,无需做任何修改
Cursor cursor = getContentResolver().query(Uri.parse("content://" + getPackageName() + ".provider.student?id=0"), null, null, null, null);
// 2. 其他进程中的使用时,需要修改uri为以下形式, 其中targetPackageName为你的App的包名
Cursor cursor = getContentResolver().query(Uri.parse("content://" + targetPackageName + ".provider/student?id=0"), null, null, null, null);
不支持和Instant Run同时使用
Amigo 不支持 Honeycomb 3.0
notification & widget中RemoteViews的自定义布局不支持修改,只支持内容修复
任何使用在RemoteViews里面的资源id都需要进行这样的包装 java RCompat.getHostIdentifier(Context context, int id)
简单来说, 你只需要下载一个全新的apk
为用户的流量着想, 你可能只想下载一个差分文件 bspatch(可针对Apk差分,或者基于Apk内容更细力度的差分)可能是你的一个选择
Copyright 2016 ELEME 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.
$ claude mcp add Amigo \
-- python -m otcore.mcp_server <graph>