Robust is an Android HotFix solution with high compatibility and high stability. Robust can fix bugs immediately without publishing apk.
More help on Wiki
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.
When you build APK,you may need to save "mapping.txt" and the files in directory "build/outputs/robust/".
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
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'
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";
}
}
Excute fellow command to build apk:
./gradlew clean assembleRelease --stacktrace --no-daemon
@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
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
.
getTextInfo(String meituan)
in class SecondActivity
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();
}
For more help, please visit Wiki
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.