• Stars
    star
    4,420
  • Rank 9,685 (Top 0.2 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

Robust

Download PRs Welcome License

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

  1. 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'
  2. 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'
       }
    }
  3. 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

  1. 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'
  2. Put mapping.txt and methodsMap.robust which are generated when you build the apks in diretory app/robust/,if not exists ,create it!

  3. 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";
             }
        }
  4. 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.

  5. Generating patches always end like this,which means patches is done Success in generating patch

Demo Usage

  1. Excute fellow command to build apk:

    ./gradlew clean  assembleRelease --stacktrace --no-daemon
  2. After install apk on your phone,you need to save mapping.txt and app/build/outputs/robust/methodsMap.robust

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

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

  5. Run the same gradle command as you build the apk:

    ./gradlew clean  assembleRelease --stacktrace --no-daemon
  6. Generating patches always end like this,which means patches is done Success in generating patch

  7. 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.

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

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

  10. 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

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

  2. 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();
    }
  3. Not Support add fields,but you can add classes currently, this feature is under testing.

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

  5. Support to fix bugs in constructors currently is under testing.

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

  7. Support to resources and so file is under testing.

  8. 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.

More Repositories

1

mpvue

基于 Vue.js 的小程序开发框架,从底层支持 Vue.js 语法和构建工具体系。
JavaScript
20,419
star
2

walle

Android Signature V2 Scheme签名下的新一代渠道包打包神器
Java
6,770
star
3

Leaf

Distributed ID Generate Service
Java
6,438
star
4

Logan

Logan is a lightweight case logging system based on mobile platform.
C
5,709
star
5

SQLAdvisor

输入SQL,输出索引优化建议
C
5,551
star
6

Zebra

美团点评集团统一使用的MySQL数据库访问层的中间件。主要提供对业务开发透明、读写分库、分库分表能力,并提供了端到端SQL监控的集成方案。
Java
2,746
star
7

DBProxy

C
2,226
star
8

beeshell

React Native 组件库
TypeScript
1,797
star
9

lyrebird

移动应用插件化测试工作台
Python
1,163
star
10

MyFlash

flashback mysql data to any point
C
1,102
star
11

Shield

A declarative, efficient, and flexible Native framework for building user interfaces.
Java
940
star
12

octo-rpc

OCTO-RPC 是支持Java和C++的企业级通信框架,在RPC服务之上扩展了丰富的服务治理功能,为美团各业务线提供高效、统一的通信服务。
Java
648
star
13

koa-restql

Build real RESTful APIs without writing one line of code.
JavaScript
447
star
14

octo-ns

OCTO-NS是美团OCTO服务治理体系服务注册发现功能的套件, 包括SDK(Java/C++)、本地服务治理代理(SgAgent), 服务缓存(NSC), 云端健康检查(Scanner)等基础组件,目前已经在全公司大规模使用
C++
327
star
15

asap

ASAP: A Chinese Review Dataset Towards Aspect Category Sentiment Analysis and Rating Prediction
311
star
16

vision-ui

视觉UI分析工具
Python
251
star
17

octo-portal

OCTO-Portal 是OCTO服务治理体系的管理端,为服务权重修改,性能数据分析等服务治理功能提供人性化的一站式管理平台
JavaScript
173
star
18

lyrebird-android

本程序是一个Lyrebird的插件,用于支持获取Android设备信息。
Python
125
star
19

vision-ml

A R-CNN machine learning model for handling Pop-up window in mobile Apps.
Python
71
star
20

lyrebird-ios

本程序是Lyrebird插件,您可以在插件中快速查看已连接iOS设备的详细设备信息,截取屏幕快照,以及查看已连接设备的应用信息。
Python
71
star
21

cat-go

Go
50
star
22

lyrebird-tracking

Tracking 是基于Lyrebird的插件,提供服务请求的数据分析及验证的功能
Python
25
star
23

lyrebird-api-coverage

API-Coverage是基于Lyrebird的插件,为客户端提供API维度测试覆盖评估方法。
Python
23
star
24

mos-mss

mtyun MSS(Meituan Storage Service) sdk for Node.js
JavaScript
19
star
25

lyrebird-java-client

lyrebird-java-client 是Lyrebird的一个 Java SDK,通过调用Lyrebird本身提供的API实现在Java项目中控制 Lyrebird Services
Java
15
star
26

lyrebird-bugit

lyrebird-bugit是Lyrebird的一个插件,目前应用于提交Bug场景
Vue
14
star
27

cat-python

Python
6
star
28

cat-node-js

CMake
5
star
29

cat-c-client

C
1
star
30

groupmeal-java-sdk

Java
1
star