Delta offers your android app the hot fix and incremental upgrade powers.
Principle
Inspired by wechat's Tinker, please check this page for more information.
Features
- Kind to developers and easy to use.
- Hot fix and incremental upgrade(on the schedule).
- Supports all platform versions.
- Fine compatibility.
- Negligible performance cost.
To be improved
- Verify patch file.
- Handle exception.
- Incremental upgrade.
- It's up to you.
How to get
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
}
Configurations
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 |
Generate patch dex
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:
How to use
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;
Partners
Looking forward to your join!