gradlew 命令
快速构建命令
./gradlew tasks --all
./gradlew assembleRelease 简写为:./gradlew aR
gradlew :app:dependencies
- 只编译清单文件,并查看具体日志,快速定位清单文件报错
gradlew :app:processDebugManifest --stacktrace:
./gradlew clean
./gradlew build
./gradlew installDebug
./gradlew build --info
./gradlew build --info --debug --stacktrace
./gradlew clean --refresh-dependencies build
注意build命令把 debug、release环境的包都打出来的如果需要指定构建使用如下命令
指定构建目标命令
./gradlew assembleDebug
简写
./gradlew aD
./gradlew assembleRelease
简写
./gradlew aR
构建并安装调试命令
./gradlew install app:assembleDebug
- Release模式打包并安装
./gradlew installRelease
./gradlew uninstallRelease
多渠道打包
assemble还可以和productFlavors结合使用,如果出现类似 Task’install’isambiguousinroot project 这种错误,请查看配置的多个渠道然后修改命令为./gradlew install[productFlavorsName] app:assembleDebug
来用命令构建调试
./gradlew assembleTestRelease
./gradlew assemble
./gradlew dependencies
./gradlew app:dependencies --configuration compile
./gradlew app:dependencies --configuration runtime
依赖管理
传递依赖特性
dependencies { transitivetrue}
手动配置transitive属性为false,阻止依赖的下载
强制
configurations.all{// transitive false// 强制指定版本resolutionStrategy{ force’org.hamcrest:hamcrest-core:1.3’// 强制不编译all*.excludegroup:‘org.hamcrest’,module:‘hamcrest-core’}}
动态依赖特性
dependencies {// 任意一个版本compile group:‘b’,name:‘b’,version:‘1.+’// 最新的版本compile group:‘a’,name:‘a’,version:‘latest.integration’}
查看详细依赖信息
./gradlew aDR --offline
./gradle build --daemon
./gradle build --parallel --parallel-threads=N
./gradle build --configure-on-demand
- 不使用snapshot依赖仓库
前提是离线可以使用时
./gradlew clean aDR
设定编码
allprojects {… tasks.withType(JavaCompile){ options.encoding =“UTF-8”}…}
仓库设置
- 设置中心仓库
默认是jcenter、可以是mavenCentral
repositories { maven { url"http://maven.oschina.net/content/groups/public"}}
Android Studio 提速
禁用插件
去掉一些没有用的插件
Google Cloud Testing、Google Cloud Tools For Android Studio、Goole Login、Google Services、JavaFX、SDK Updater、TestNG-J欢迎使用ShowDoc!