byteam / delta
- суббота, 10 сентября 2016 г. в 03:13:01
C
Android热修复与增量升级,基于微信Tinker原理
Delta offers your android app the hot fix and incremental upgrade powers.
Inspired by wechat's Tinker, please check this page for more information.
In your project's build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:x.y.z'
classpath 'org.byteam.delta:delta-gradle-plugin:x.y.z'
...
}
}
In your application module's build.gradle
apply plugin: 'com.android.application'
apply plugin: 'delta'
...
delta {
enable true
autoPushPatchToDevice true // for test
}
Avaliable options:
option | type | usage | default |
---|---|---|---|
enable | boolean | enable delta or not | false |
versionCode | int | specify application's version code | variant's version code |
deltaVersion | String | specify delta library's version | same as plugin version |
maxNumberOfIdxPerDex | int | max number of methods in per dex | 0xFF00 |
mapping | String | specify the mapping file | null |
autoPushPatchToDevice | boolean | auto push patch to device rom, used for test | fale |
The delta gradle plugin will create some tasks:
The final patch directory looks like this:
In your own Application
:
public class App extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// Install existing patch
Delta.install(this);
}
...
}
/**
* 从手机内存中应用patch,一般用于测试,切勿在正式环境中使用.
*
* @param context Context
*/
Delta.applyPatchFromDevice(Context context);
/**
* 应用指定的patch. 该操作为耗时操作,建议放到非UI线程执行.
*
* @param context Context
* @param patchDex patch文件
*/
Delta.applyPatch(Context context, File patchDex);
/**
* 删除所有补丁.
*
* @param context Context
*/
Delta.clean(Context context;
Looking forward to your join!