Skip to content

Commit 064b84e

Browse files
committed
init Aceso.
Signed-off-by: wangzhi <[email protected]>
0 parents  commit 064b84e

File tree

104 files changed

+7523
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+7523
-0
lines changed

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.idea
2+
*.iml
3+
.gradle
4+
local.properties
5+
.DS_Store
6+
build
7+
aceso-demo-fix/app/libs/
8+
gradlew
9+
gradlew.bat
10+
*/gradle/wrapper
11+
/captures
12+
.externalNativeBuild
13+
14+
15+

LICENSE

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Apache License
2+
3+
Version 2.0, January 2004
4+
5+
http://www.apache.org/licenses/
6+
7+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8+
9+
1. Definitions.
10+
11+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
12+
13+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
14+
15+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
16+
17+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
18+
19+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
20+
21+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
22+
23+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
24+
25+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
26+
27+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
28+
29+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
30+
31+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32+
33+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
34+
35+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
36+
37+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
38+
You must cause any modified files to carry prominent notices stating that You changed the files; and
39+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
40+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
41+
42+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
43+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
44+
45+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
46+
47+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
48+
49+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
50+
51+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
52+
53+
END OF TERMS AND CONDITIONS
54+
55+
APPENDIX: HOW TO APPLY THE APACHE LICENSE TO YOUR WORK
56+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
57+
58+
Copyright [yyyy] [name of copyright owner]
59+
60+
Licensed under the Apache License, Version 2.0 (the "License");
61+
you may not use this file except in compliance with the License.
62+
You may obtain a copy of the License at
63+
64+
http://www.apache.org/licenses/LICENSE-2.0
65+
66+
Unless required by applicable law or agreed to in writing, software
67+
distributed under the License is distributed on an "AS IS" BASIS,
68+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
69+
See the License for the specific language governing permissions and
70+
limitations under the License.

README-zh.md

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
## Aceso
2+
3+
Aceso是基于Instant Run Hot Swap的Android热修复方案,使用它你能在不用重新发布版本的情况下对线上app的bug进行修复。
4+
5+
## Features
6+
7+
- 支持4.x-7.x机型
8+
- 相比业界其他方案,基本没有兼容性问题
9+
- 安装补丁后不用重启,实时生效
10+
- 支持方法级别的修复
11+
- 支持新增类
12+
13+
14+
## Limitations
15+
16+
- 暂不支持static函数、构造函数的修复
17+
- 被proguard shrink或inline掉的函数不能修复
18+
- 只支持修改函数体
19+
20+
21+
22+
## Usage
23+
1.在最外层project的build.gradle中加入以下代码:
24+
25+
```
26+
buildscript {
27+
repositories {
28+
jcenter()
29+
}
30+
31+
dependencies {
32+
classpath 'com.mogujie.aceso:aceso-build:0.0.1'
33+
}
34+
}
35+
```
36+
37+
2.在module的build.gradle中加入以下代码:
38+
39+
```
40+
apply plugin: 'Aceso'
41+
42+
dependencies {
43+
compile 'com.mogujie.aceso:aceso-android-lib:0.0.1'
44+
}
45+
46+
```
47+
48+
如果你要在debug版本中使用aceso,需要再加入如下代码:
49+
50+
```
51+
Aceso {
52+
instrumentDebug = false
53+
}
54+
```
55+
56+
3.在合适的位置加入如下代码:
57+
58+
```
59+
new Aceso().installPatch(optDir, patchFile);
60+
```
61+
62+
4.每次**发布版本**时需要将module目录下的build/intermediates/aceso文件夹保存下来
63+
64+
65+
## Generate Patch
66+
1.你需要创建一个额外Fix的工程(可参考[aceso-demo-fix](aceso-demo-fix)
67+
68+
2.在最外层project的build.gradle中加入以下代码:
69+
70+
```
71+
buildscript {
72+
repositories {
73+
jcenter()
74+
}
75+
76+
dependencies {
77+
classpath 'com.mogujie.aceso:aceso-build:0.0.1'
78+
}
79+
}
80+
```
81+
82+
3.在module的build.gradle中加入以下代码:
83+
84+
```
85+
apply plugin: 'AcesoFix'
86+
87+
Aceso {
88+
//methodLevelFix为true时,是方法级的fix,也就是只对特定的方法进行修复,需要在修的方法前加@FixMtd的注解。否则是对整个类的所有方法进行修复。
89+
methodLevelFix = true
90+
//下面文件都在Usage第4步提到的aceso文件夹中,各个文件的作用请参考wiki
91+
instrumentJar = ‘宿主工程生成的instrument.jar的路径’
92+
allClassesJar = ‘宿主工程生成的all-classes.jar的路径’
93+
acesoMapping = ‘宿主工程生成的aceso-mapping.txt的路径’
94+
}
95+
96+
```
97+
98+
99+
4.将需要修改的类拷贝到Fix工程,并且保证包名不变。比如你需要修改的类为com.mogujie.aceso.demo.MainActivity,则你需要保证在fix工程中MainActivity的全限定名也为com.mogujie.aceso.demo.MainActivity。
100+
101+
5.进行你需要的修改
102+
103+
6.如果你将methodLevelFix设置为true,则需要对你修改的方法前加入@FixMtd的注解(com.android.annotations.FixMtd)
104+
105+
7.执行gradle/.gradlew acesoRelease(或acesoDebug)命令生成对应的补丁包。补丁包在/build/outputs/apk目录下
106+
107+
8.将补丁包下发到手机。
108+
109+
110+
## Demo
111+
1.编译并安装aceso-demo,点击test按钮,显示的是not fix!
112+
113+
2.在aceso-demo-fix中执行gradle/.gradlew acesoRelease(或acesoDebug)
114+
115+
3.将产生的apk包push到手机端的/sdcard/fix.apk
116+
117+
4.在手机上点击fix按钮
118+
119+
5.点击test按钮,显示的是has been fixed !
120+
121+
122+
## Thanks
123+
- [Instant Run](https://developer.android.com/studio/run/index.html#instant-run)
124+
- [Robust](http://tech.meituan.com/android_robust.html)
125+
126+
127+
## License
128+
129+
Aceso is under the [Apache 2.0](LICENSE) license.

README.md

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
## Aceso
2+
3+
Aceso is a Android HotFix by optimizing the AOSP's "InstantRun HotSwap" solution, it is used to fix online bugs without a new APK publish.
4+
5+
## Features
6+
7+
- Support 4.x to 7.0 Android OS
8+
- Perfect compatibility
9+
- Taking effect immediately after download without reboot
10+
- Support fixing at method level
11+
- Support adding new classes
12+
13+
## Limitations
14+
15+
- Current not support fixing static function and constructors.
16+
- Functions that shrinked/inlined by proguard are NOT repariable.
17+
- Only the Method's body can be fixed.
18+
19+
20+
## Usage
21+
1.Add below codes in the outest project's build.gradle file
22+
23+
```
24+
buildscript {
25+
repositories {
26+
jcenter()
27+
}
28+
29+
dependencies {
30+
classpath 'com.mogujie.aceso:aceso-build:0.0.1'
31+
}
32+
}
33+
```
34+
35+
2.Add below codes in the module's build.gradle
36+
37+
```
38+
apply plugin: 'Aceso'
39+
40+
dependencies {
41+
compile 'com.mogujie.aceso:aceso-android-lib:0.0.1'
42+
}
43+
44+
```
45+
46+
Add below codes once you need aceso for Debug version.
47+
48+
```
49+
Aceso {
50+
instrumentDebug = false
51+
}
52+
```
53+
54+
3.Add below codes at the place after HotFix downloaded and Application's onAttachedBaseContext() or onCreate()
55+
56+
```
57+
new Aceso().installPatch(optDir, patchFile);
58+
```
59+
4.Pls. reserve the file folder "build/intermediates/aceso" under module directory at each HotFix publishment.
60+
61+
## Generate Patch
62+
1.An additional Fix project is needed(pls. refer to [aceso-demo-fix](aceso-demo-fix))
63+
64+
2.Pls. add below codes in the outest prject's build.gradle:
65+
66+
```
67+
buildscript {
68+
repositories {
69+
jcenter()
70+
}
71+
72+
dependencies {
73+
classpath 'com.mogujie.aceso:aceso-build:0.0.1'
74+
}
75+
}
76+
```
77+
78+
3.Pls. add below codes in the module's build.gradle:
79+
80+
```
81+
apply plugin: 'AcesoFix'
82+
83+
Aceso {
84+
// The HotFix is for method level once methodLevelFix set to true, i.e., only fix the designated method, the annotation @FixMtd should be added above the method to be fixed. Once set to false, the HotFix is for class level.
85+
methodLevelFix = true
86+
// Below files are those aceso file folders whch mentioned in 4th step of Usage, pls. refer to the file usage in the wiki.
87+
instrumentJar = ‘The path of instrument.jar which generated in host project’
88+
allClassesJar = ‘The path of all-classes.jar which generated in host project’
89+
acesoMapping = ‘The path of aceso-mapping.txt which generated in host project’
90+
}
91+
92+
```
93+
94+
4.Pls copy the class to be fixed to Fix project, and reserve the package name, e.g., the class to be fixed named 'com.mogujie.aceso.demo.MainActivity', the MainActivity in fix project should reserve the package name as 'com.mogujie.aceso.demo.MainActivity'.
95+
96+
5.Fix you bug in Fix project.
97+
98+
6.Pls. add @FixMtd above the method to be fixed once methodLevelFix is set.
99+
100+
7.Execute command 'gradle acesoRelease(or acesoDebug)' to generate the patch package, the patch would be generated under directory build/outputs/apk
101+
102+
8.Deploy the patch to the target phones.
103+
104+
## Demo
105+
1.Compile and install aceso-demo, press the test button, the 'not fix' would be displayed
106+
107+
2.Execute command 'gradle acesoRelease(or acesoDebug) in project 'aceso-demo-fix'
108+
109+
3.Use 'adb push' command to push the apk generated to path '/sdcard/fix.apk'
110+
111+
4.Press fix button on the phone
112+
113+
5.Press test button, the 'has been fixed' would be displayed!
114+
115+
116+
## Thanks
117+
- [Instant Run](https://developer.android.com/studio/run/index.html#instant-run)
118+
- [Robust](http://tech.meituan.com/android_robust.html)
119+
120+
121+
## License
122+
123+
Aceso is under the [Apache 2.0](LICENSE) license.

0 commit comments

Comments
 (0)