android使用tinker对app进行热修复
2017-10-25 11:53
344 查看
记录一下热更新流程,方便以后使用。
tinker项目地址:
https://github.com/Tencent/tinker
项目里包含了lib的源码和sample,下下来,然后打开tinker-sample-android:
修改mainActivity中textview:
通过gradle生成release版的apk:
在app/build/bakApk目录下会生成apk,混淆映射文件和资源文件:
通过adb运行:
下面修改app的build.gradle文件:
将打包生成的老apk的三个文件对应填入tinkerOldApkPath、tinkerApplyMappingPath、tinkerApplyResourcePath,然后我们准备新版本apk,修改代码,也是改mainactivity中的textview:
不要clean,不然android studio会删除之前打包好的apk,然后用gradle里的tinker打包:
会生成新的release版apk:
tinker对比新旧apk的差异生成一个补丁文件patch_signed_7zip.apk:
把这个补丁文件push到手机内存根目录:
回到运行的app中,点击LOAD PATCH:
然后点击KILL SELF,再次进入app,改动就生效了,同时删除了存储卡上的补丁文件:
demo里还提供了去掉补丁功能,点击CLEAN PATCH,再KILL SELF,重启app就是旧的版本。
tinker项目地址:
https://github.com/Tencent/tinker
项目里包含了lib的源码和sample,下下来,然后打开tinker-sample-android:
修改mainActivity中textview:
<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This is old apk"/>
通过gradle生成release版的apk:
在app/build/bakApk目录下会生成apk,混淆映射文件和资源文件:
通过adb运行:
adb install -r -d F:\AndroidProgram\Demo\tinker\tinker-sample-android\app\build\bakApk\app-release-1025-10-46-35.apk
下面修改app的build.gradle文件:
ext { //for some reason, you may want to ignore tinkerBuild, such as instant run debug build? tinkerEnabled = true //for normal build //old apk file to build patch apk tinkerOldApkPath = "${bakPath}/app-release-1025-10-46-35.apk" //proguard mapping file to build patch apk tinkerApplyMappingPath = "${bakPath}/app-release-1025-10-46-35-mapping.txt" //resource R.txt to build patch apk, must input if there is resource changed tinkerApplyResourcePath = "${bakPath}/app-release-1025-10-46-35-R.txt" //only use for build all flavor, if not, just ignore this field tinkerBuildFlavorDirectory = "${bakPath}/app-1018-17-32-47" }
将打包生成的老apk的三个文件对应填入tinkerOldApkPath、tinkerApplyMappingPath、tinkerApplyResourcePath,然后我们准备新版本apk,修改代码,也是改mainactivity中的textview:
<TextView android:id="@+id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="This is new apk"/>
不要clean,不然android studio会删除之前打包好的apk,然后用gradle里的tinker打包:
会生成新的release版apk:
tinker对比新旧apk的差异生成一个补丁文件patch_signed_7zip.apk:
把这个补丁文件push到手机内存根目录:
adb push F:\AndroidProgram\Demo\tinker\tinker-sample-android\app\build\outputs\tinkerPatch\release\patch_signed_7zip.apk /sdcard/
回到运行的app中,点击LOAD PATCH:
然后点击KILL SELF,再次进入app,改动就生效了,同时删除了存储卡上的补丁文件:
demo里还提供了去掉补丁功能,点击CLEAN PATCH,再KILL SELF,重启app就是旧的版本。
相关文章推荐
- android 微信热修复Tinker接入过程以及使用方法
- 使用Fiddler对Android App进行抓包的步骤详解
- Android热修复之Tinker使用初探
- iOS 【使用 dSYM 符号集对线上 App 进行崩溃修复】
- Android 热修复Tinker 在项目中的使用
- 【Android端 APP 内存分析】使用工具进行APP的内存分析
- Android热修复之微信Tinker使用初探
- android 热修复框架Tinker的详细简单使用
- Android中使用NativeActivity进行APP开发
- 【Android Training - 15】云同步的实现 [Lesson 1 - 使用App Engine进行同步]
- Android集成微信Tinker热修复及使用
- 使用react-native进行android App开发过程所遇到的问题集锦
- android tinker 热修复使用及注意事项
- 使用Facebook的Redex工具进行android app运行优化
- 【Android】微信热修复 Tinker 的集成和使用
- Android APP 使用Bugly进行APP质量跟踪
- [Android]腾讯Tinker热修复框架简单使用
- Android 微信热修复 Tinker 接入过程及使用方法
- Android App中使用LinearLayout进行居中布局的实例讲解
- Android热修复之微信Tinker使用初探