AutoPatch java_Robust新一代热更新系统,对Android版本无差别兼容

Robust

68747470733a2f2f6170692e62696e747261792e636f6d2f7061636b616765732f6d65697475616e2f6d6176656e2f636f6d2e6d65697475616e2e726f6275737425334170617463682f696d616765732f646f776e6c6f61642e7376673f76657273696f6e3d302e342e393968747470733a2f2f696d672e736869656c64732e696f2f62616467652f5052732d77656c636f6d652d627269676874677265656e2e73766768747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d417061636865253230322e302d626c75652e737667

Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without publishing apk.

More help on Wiki

Environment

Mac Linux and Windows

Gradle 2.10+ , include 3.0

Java 1.7 +

Usage

Add below codes in the module's build.gradle.

apply plugin: 'com.android.application'

//please uncomment fellow line before you build a patch

//apply plugin: 'auto-patch-plugin'

apply plugin: 'robust'

compile 'com.meituan.robust:robust:0.4.99'

Add below codes in the outest project's build.gradle file.

buildscript {

repositories {

jcenter()

}

dependencies {

classpath 'com.meituan.robust:gradle-plugin:0.4.99'

classpath 'com.meituan.robust:auto-patch-plugin:0.4.99'

}

}

There are some configure items in app/robust.xml,such as classes which Robust will insert code,this may diff from projects to projects.Please copy this file to your project.

Advantages

Support 2.3 to 10 Android OS

Perfect compatibility

Patch takes effect without a reboot

Support fixing at method level,including static methods

Support add classes and methods

Support ProGuard,including inline methods or changing methods' signature

When you build APK,you may need to save "mapping.txt" and the files in directory "build/outputs/robust/".

AutoPatch

AutoPatch will generate patch for Robust automatically. You just need to fellow below steps to genrate patches. For more details please visit website http://tech.meituan.com/android_autopatch.html

Steps

Put 'auto-patch-plugin' just behind 'com.android.application',but in the front of others plugins。like this:

apply plugin: 'com.android.application'

apply plugin: 'auto-patch-plugin'

Put mapping.txt and methodsMap.robust which are generated when you build the apks in diretory app/robust/,if not exists ,create it!

After modifying the code ,please put annotation @Modify on the modified methods or invoke RobustModify.modify() (designed for Lambda Expression )in the modified methods:

@Modify

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

}

//

protected void onCreate(Bundle savedInstanceState) {

RobustModify.modify()

super.onCreate(savedInstanceState);

}

Use annotation @Add when you neeed to add methods or classes.

//add method

@Add

public String getString() {

return "Robust";

}

//add class

@Add

public class NewAddCLass {

public static String get() {

return "robust";

}

}

After those steps,you need to run the same gradle command as you build the apk,then you will get patches in directory app/build/outputs/robust/patch.jar.

Generating patches always end like this,which means patches is done patchsuccess_en.png

Demo Usage

Excute fellow command to build apk:

./gradlew clean assembleRelease --stacktrace --no-daemon

After install apk on your phone,you need to save mapping.txt and app/build/outputs/robust/methodsMap.robust

Put mapping.txt and methodsMap.robust which are generated when you build the apks into diretory app/robust/,if directory not exists ,create it!

After modifying the code ,please put annotation @Modify on the modified methods or invoke RobustModify.modify() (designed for Lambda Expression )in the modified methods.

Run the same gradle command as you build the apk:

./gradlew clean assembleRelease --stacktrace --no-daemon

Generating patches always end like this,which means patches is done patchsuccess_en.png

Copy patch to your phone:

adb push ~/Desktop/code/robust/app/build/outputs/robust/patch.jar /sdcard/robust/patch.jar

patch directory can be configured in PatchManipulateImp.

Open app,and click Patch button,patch is used.

Also you can use our sample patch in app/robust/sample_patch.jar ,this dex change text after you click Jump_second_Activity Button.

In the demo ,we change the text showed on the second activity which is configured in the method getTextInfo(String meituan) in class SecondActivity

Attentions

You should modify inner classes' private constructors to public modifier.

AutoPatch cannot handle situations which method returns this,you may need to wrap it like belows:

method a(){

return this;

}

changed to

method a(){

return new B().setThis(this).getThis();

}

Not Support add fields,but you can add classes currently, this feature is under testing.

Classes added in patch should be static nested classes or non-inner classes,and all fields and methods in added class should be public.

Support to fix bugs in constructors currently is under testing.

Not support methods which only use fields,without method call or new expression.

Support to resources and so file is under testing.

For more help, please visit Wiki

License

Copyright 2017 Meituan-Dianping

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值