«

Gradle常用的命令

Gradle 常用的命令 (gradle 是全局gradle环境,./gradlew 在项目下进行,用的是项目的gradle),尝试着通过控制台调试运行程序 ​

1、打包运行命令

./gradlew build 检查依赖并编译打包   把debug、release环境的包都打出来

./gradlew assembleDebug  编译并打Debug包
./gradlew assembleRelease  编译并打Release的包

Debug包: ./gradlew installDebug   打包并运行到手机上

Release包: ./gradlew installRelease  打包并运行到手机上

./gradlew uninstallRelease 卸载Release模式包

2、运行task

./gradle  task名称..  后面可追加任务
eg. dist test两个任务  
./gradle dist test

排除任务:可以用-x参数排除某个任务:
./gradle dist -x test   运行dist而不运行test

3、出错时继续运行

./gradle --continue   Gradle在出现错误的时候继续执行构建过程,直到每个任务都运行完毕。然后Gradle会报告所有错误

4、列出任务

./gradle -q tasks

5、查看依赖树

./gradlew app:dependencies -q --configuration compile

6、查看错误信息

./gradlew compileDebugSource --stacktrace -info
./gradlew processDebugManifest —stacktrace
./gradlew compileDebugJavaWithJavac


​ ​
​ ​
​ ​
​ ​ ​ ​ ​

Share Comment on Twitter