Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

更新描述编译示例app的部分文档,更新示例app的robust 插件版本 #454

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 74 additions & 33 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@


Robust是新一代热更新系统,无差别兼容Android2.3-10版本;无需重启补丁实时生效,快速修复线上问题,补丁修补成功率高达99.9%。

[English Introduction](README.md)

关于如何自定义以及常见问题的解决,请参看 [Wiki](https://github.com/Meituan-Dianping/Robust/wiki)

# 环境
Expand All @@ -18,7 +18,7 @@
* Java 1.7 +

# 使用方法

1. 在App的build.gradle,加入如下依赖

```java
Expand All @@ -32,7 +32,7 @@

```
2. 在整个项目的build.gradle加入classpath

```java
buildscript {
repositories {
Expand All @@ -45,7 +45,7 @@
}
```
3. 在项目的src同级目录下配置robust.xml文件,具体项请参考DEMO**app/robust.xml**

# 优势

* 支持Android2.3-10版本
Expand All @@ -63,8 +63,8 @@
}

# AutoPatch


Robust补丁自动化,为Robust自动生成补丁,使用者只需要提交修改完bug后的代码,运行和线上apk打包同样的gradle命令即可,会在项目的app/build/outputs/robust目录下生成补丁。更多自动化补丁信息请参考:[Android热更新方案Robust开源,新增自动化补丁工具](http://tech.meituan.com/android_autopatch.html) 。

# 使用方法
Expand Down Expand Up @@ -112,31 +112,72 @@ Robust补丁自动化,为Robust自动生成补丁,使用者只需要提交
5. 补丁制作成功后会停止构建apk,出现类似于如下的提示,表示补丁生成成功
![补丁制作成功图片](images/patchsuccess_cn.png)

# 样例使用:
1. 生成样例apk,执行gradle命令:
# 样例使用

```java
./gradlew clean assembleRelease --stacktrace --no-daemon
```
2. 安装样例apk。保存mapping.txt文件以及app/build/outputs/robust/methodsMap.robust文件
3. 修改代码之后,加上**@Modify**注解或者调用RobustModify.modify()方法
4. 把保存的**mapping.txt**和**methodsMap.robust**放到app/robust目录下
5. 执行与生成样式apk相同的gradle命令:

```java
./gradlew clean assembleRelease --stacktrace --no-daemon
```
5. 补丁制作成功后会停止构建apk,出现类似于如下的提示,表示补丁生成成功
![补丁制作成功图片](images/patchsuccess_cn.png)
7. 将补丁文件copy到手机目录/sdcard/robust下
## 预编译版本

```java
adb push ~/Desktop/code/robust/app/build/outputs/robust/patch.jar /sdcard/robust/patch.jar
```
补丁的路径/sdcard/robust是`PatchManipulateImp`中指定的
8. 打开App,点击Patch按钮就会加载补丁。
9. 也可以加载app/robust的样例补丁,修改了Jump_second_Activity跳转Activity的显示文字。
10. 在样例中我们给类```SecondActivity```的方法```getTextInfo(String meituan)```制作补丁,你可以自行定制。
`app/robust` 目录下已经预先编译了 apk 和 `patch.jar`,可以预览效果。

1. 安装 `app/robust` 目录下的 apk。

2. 打开App,点击 Jump_second_Activity,可以看到显示 error occur。

3. 推送 patch 到指定目录

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

4. 打开App,点击Patch按钮加载补丁。

5. 再次点击 Jump_second_Activity,可以看到显示 error fixed。

## 自行编译(以修改类 ```SecondActivity``` 为例子)

1. 可以删除 `app/robust` 中的所有文件,其为预编译样例文件。

2. 生成样例apk,执行gradle命令:

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

3. 安装编译完成的 apk `app/build/outputs/apk/app-release.apk` 。保存 `app/build/outputs/mapping/release/mapping.txt `文件以及 `app/build/outputs/robust/methodsMap.robust` 文件。

4. 修改代码之后,加上**@Modify**注解或者调用RobustModify.modify()方法

* 这里可以修改类 ```SecondActivity ```的方法 ```getTextInfo()``` 的返回值,制作补丁。

5. 修改 `app/build.gradle` 文件的头部,使用插件。

```java
// 取消下面行的注释
apply plugin: 'auto-patch-plugin'
```

6. 把保存的**mapping.txt**和**methodsMap.robust**放到 `app/robust` 目录下,如果目录不存在,创建目录。

7. 执行与生成样式apk相同的gradle命令:

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

8. 补丁制作成功后会停止构建apk,出现类似于如下的提示,表示补丁生成成功
![补丁制作成功图片](images/patchsuccess_cn.png)

9. 将补丁文件copy到手机目录 /sdcard/robust 下

```java
adb push ~/Desktop/code/robust/app/build/outputs/robust/patch.jar /sdcard/robust/patch.jar
```
补丁的路径/sdcard/robust是`PatchManipulateImp`中指定的

10. 打开App,点击 Jump_second_Activity,可以预览修改前的Activity 的显示文字。

11. 点击Patch按钮就会加载补丁。

12. 点击 Jump_second_Activity,可以看到 Activity 的显示文字被修改了。

# 注意事项

Expand Down Expand Up @@ -165,13 +206,13 @@ Robust补丁自动化,为Robust自动生成补丁,使用者只需要提交
## 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.
Expand Down
117 changes: 80 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@

# Robust

[![Download](https://api.bintray.com/packages/meituan/maven/com.meituan.robust%3Apatch/images/download.svg?version=0.4.99) ](https://bintray.com/meituan/maven/com.meituan.robust%3Apatch/0.4.99/link)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Meituan-Dianping/Robust/pulls)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://raw.githubusercontent.com/Meituan-Dianping/Robust/master/LICENSE)

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

[中文说明](README-zh.md)

More help on [Wiki](https://github.com/Meituan-Dianping/Robust/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.

```java
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'
```java
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.

Expand Down Expand Up @@ -58,7 +59,7 @@ Robust is an Android HotFix solution with high compatibility and high stability.
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

Expand Down Expand Up @@ -108,30 +109,72 @@ AutoPatch will generate patch for Robust automatically. You just need to fellow
![Success in generating patch](images/patchsuccess_en.png)

# Demo Usage
1. Excute fellow command to build apk:

```java
./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:
## Pre Compile

```java
./gradlew clean assembleRelease --stacktrace --no-daemon
```
6. Generating patches always end like this,which means patches is done
![Success in generating patch](images/patchsuccess_en.png)
7. Copy patch to your phone:
The apk and patch.jar have been pre-compiled in the `app/robust` folder, and the patch effect can be previewed.

```java
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```
1. Install the apk in the `app/robust`.

2. Open the App, click `Jump_second_Activity`, you can see that `error occur` appears.

3. Push the patch to the specified directory

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

4. Open the App and click the `Patch` button to load the patch.

5. Click `Jump_second_Activity` again, you can see `error fixed` is displayed.

## Compile by yourself (take Class ```SecondActivity``` as an example)

1. You can delete all files in `app/robust`, which are pre-compiled sample files.

2. Generate a sample apk and execute the gradle command:

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

3. Install the compiled apk `app/build/outputs/apk/app-release.apk` . Save the `app/build/outputs/mapping/release/mapping.txt` file and the `app/build/outputs/robust/methodsMap.robust` file

4. After modifying the code, add **@Modify** annotation or call RobustModify.modify() method

* Here you can modify the return value of the method ```getTextInfo()``` of the class ```SecondActivity ```, and make a patch.

5. Modify the header of the `app/build.gradle` file to use plugins.

```java
// Uncomment the following line
apply plugin:'auto-patch-plugin'
```

6. Put the saved **mapping.txt** and **methodsMap.robust** in the `app/robust` folder, create the folder if not exist.

7. Execute the same gradle command as the generated the sample apk:

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

8. After the patch is successfully made, the apk will stop building, and a prompt similar to the following appears, indicating that the patch is successfully generated
![Picture of successful patch production](images/patchsuccess_en.png)

9. Copy the patch file to the phone directory `/sdcard/robust`

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

The patch path `/sdcard/robust` is specified in `PatchManipulateImp`

10. Open the App and click `Jump_second_Activity` to preview the display text of the Activity before modification.

11. Click the `Patch` button to load the patch.

12. Click ` Jump_second_Activity`, you can see that the display text of Activity has been modified.

# Attentions

Expand Down Expand Up @@ -159,13 +202,13 @@ AutoPatch will generate patch for Robust automatically. You just need to fellow
## 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.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ buildscript {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.meituan.robust:gradle-plugin:0.4.96'
classpath 'com.meituan.robust:auto-patch-plugin:0.4.96'
classpath 'com.meituan.robust:gradle-plugin:0.4.99'
classpath 'com.meituan.robust:auto-patch-plugin:0.4.99'
classpath 'me.tatarka:gradle-retrolambda:3.2.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
Expand Down