1 Root Program
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.1.0-rc1' classpath 'cn.jiajixin.nuwa:gradle:1.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } }
2 module build.gradle
add apply plugin: "cn.jiajixin.nuwa"
apply plugin: 'com.android.application'apply plugin: "cn.jiajixin.nuwa"
and
dependencies:
dependencies {
compile 'cn.jiajixin.nuwa:nuwa:1.0.0'
}
原来是 gradle 版本不支持的原因:
如果用此版本,会报错Error:Cannot get property 'taskDependencies' on null object,乖乖降低到1.2.3,木有此问题
如果,这里的版本修改了话, 对应的这里的版本也要修改:
之前用的是 2.10 改成 2.2
有问题的版本
classpath 'com.android.tools.build:gradle:2.1.0-rc1'
classpath 'com.android.tools.build:gradle:1.5.0'
You can see the detail: how to resolve it?
这个地方要
download the new gradlew version
So it is maybe so slow!
ProGuard
-keep class cn.jiajixin.nuwa.** { *; }
Now we can change the code and build the apk:
How to use Nuwa:
1 设置配置信息
初始化 和 加载路径
*/public class HadesApplication extends Application{ @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); Nuwa.init(this); Nuwa.loadPatch(this,"/sdcard/patch.jar"); } }
将这个目录copy 到 一个指定的目录;
Documents/Code/nuwa
3 修改你的代码 或者 你的bug 然后执行下面的命令
./gradlew clean nuwaDebugPatch -P NuwaDir=/Users/Hades/Documents/Code/nuwa
然后会在 app/build/output/nuwa/debug/目录下面生成 patch.jar 文件
这就是我们的补丁文件,
这个时候我遇到一个问题:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:nuwaDebugPatch'.
> $ANDROID_HOME is not defined
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
THanks to:
https://github.com/GeekHades/Nuwa
http://www.jianshu.com/p/72c17fb76f21
No comments:
Post a Comment