Delta offers your android app the hot fix and incremental upgrade powers.
Inspired by wechat's Tinker, please check this page for more information.
- Kind to developers and easy to use.
- Hot fix and incremental upgrade(on the schedule).
- Supports all platform versions.
- Fine compatibility.
- Negligible performance cost.
- Verify patch file.
- Handle exception.
- Incremental upgrade.
- It's up to you.
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:
- Execute backup task to backup the dex and mapping files for future usage.
- Find bugs, fix it(change some code).
- Execute patch task, this task will apply existing mapping or specifed mapping and generate a new dex, then produce the final patch.
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;