https://www.jb51.net/article/149128.htm
https://www.codercto.com/a/104434.html
https://www.cnblogs.com/SZ2015/p/6884792.html ----总体优化
https://blog.csdn.net/bencheng06/article/details/83934814 -----gradle 自动化构建之旅,实现持续集成,自动构建,很腻害的文章
1:在.gradle目录下的 gradle.properties文件中配置 并行线程(开启Gradle单独守护线程)
2: dexOptions :控制代码打包细节:解决64k问题,配置dex运行内存
https://blog.csdn.net/weixin_37625173/article/details/103334208
3:混淆移除无用资源
https://blog.csdn.net/u013620306/article/details/107692352
4:增量编译
5:配置多渠道打包
productFlavors {
//基础版本
basic { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "basic"] }
//腾讯应用宝版本
yyb { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "yyb"] }
//华为应用市场
huawei { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "huawei"] }
//小米应用市场
xiaomi { manifestPlaceholders = [UMENG_CHANNEL_VALUE: "xiaomi"] }
}
出现异常:
解决异常 在defaultConfig {
flavorDimensions "default"
}
6:配置gradle命令
https://blog.csdn.net/u011287967/article/details/80884244
7: gradle开启缓存构建 ??? 是否需要增量构建插件 ??(Gradle在编译之前,会检查输入、输出,若无变化,则不会重复编译。这是Gradle编译速度提升的重要原因。)
新的工程使用Android Gradle 插件2.3.0或者更高版本默认就开启了构建缓存(除非你手动关闭了)
8:获取构建的profile
直接在Terminal命令行中输入:gradlew --profile --recompile-scripts --offline --rerun-tasks assembleHuaweiDebug
(命令分析:
--profile
: 开启profiling (If we want to know more about how much time is spent in tasks we can use the--profile
command-line option. Gradle will generate a report file in thebuild/reports/profile
directory. This report file is a HTML file with information about how much time is spent by the different tasks and processes of Gradle.
The following report file is for a Gradle project with the Groovy plugin and we invoked$ gradle --profile build
:)--recompile-scripts
: 强制脚本重新编译跳过cache--offline
:禁止 Gradle获取离线依赖,这是确保任何的延迟都是Gradle试图更新依赖而导致,不会误导你的分析数据。你应该先准备好构建一次工程确保Gradle 已经下载好并且缓存依赖。--rerun-tasks
:强制Gradle返回所有task 并且忽略任何task 优化。)- 构建的文件
- 结果分析