由于今天做开发完了一个版本,测试不在,准备明天测试,于是我就研究了一下android的热更新技术。首个学习的热更新框架是Nuwa(女娲)。
一、Nuwa的github的介绍:
Nuwa的github地址:https://github.com/jasonross/Nuwa
Nvwa的介绍:Nuwa is a goddess in ancient Chinese mythology best known for repairing the pillar of heaven.
二、Nuwa的使用:
在github上有nvwa的使用,但是对于我这种级别的英文和技术小渣渣来说还是难整明白的。原文介绍如下:
-
in
master
branch, run and install the app.it shows『hello world』.
-
copy sample/build/outputs/nuwa dir to somewhere for later use.
for example: /Users/jason/Documents/nuwa
-
change to
bugfix
branch, run the following command in terminal to generate patch.jar../gradlew clean nuwaQihooDebugPatch -P NuwaDir=/Users/jason/Documents/nuwa
java verison must be same using android studio and terminal
-
run following command to push patch.jar to sdcard.
adb push sample/build/outputs/nuwa/qihoo/debug/patch.jar /sdcard/
-
restart your application (kill the process).
it shows『patch success』.
三、实验:
这里只是介绍使用,也就是修改“hello world”的值为“欢迎来到安卓技术交流群”,我也就不自己创建工程了,我就用githut上的Nuwa上sample做实验。
1. clone下Nuwa-master的代码:git clone https://github.com/jasonross/Nuwa.git
2. studio 打开项目:
3.项目build通过的情况下,部署到安卓手机(我用都是真机)
运行结果显示 “hello world”,如下图:
4. 在生成patch.jar之前需要把sample/build/outputs/nuwa文件夹copy到一个方便的位置,在后面会用到,我这里就放到桌面了。我的路径为:C:\Users\Administrator\Desktop\nuwa
5. 修改say方法:
原方法是:
修改后的方法是:
6.生成patch.jar
为甚什么要生成patch.jar尼?理由如下:
接下来就是使用命令生成patch.jar了。
生成命令:
gradlew clean nuwaQihooDebugPatch -P NuwaDir=C:/Users/
Administrator/Desktop/nuwa
看看我这边的生成过程截图:
看到BUILD SUCCESSFUL了吧,很开心了。之后看看patch.jar文件有没有生成吧。检查sample\build\outputs\nuwa\qihoo\debug目录,发现有pathc.jar。如下图:
7.把pathc.jar放到手机的sd卡上面。(这个往安卓手机的sd上放一个文件我就不描述了)
8.杀死显示hello world的app的进程。再打开app:于是看到“hello world” 变成“欢迎来到安卓技术交流群”了。如下图:
于是这个简单的Nvwa的使用就介绍完了。欢迎指导交流。