Gradled编译打包后可以注意的

发布时间:2026/8/16 8:21:25
Gradled编译打包后可以注意的 [Incubating] Problems report is available at: file:///E:/xxx/build/reports/problems/problems-report.htmlDeprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.For more on this, please refer to https://docs.gradle.org/8.14/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.BUILD SUCCESSFUL in 2m 35s83 actionable tasks: 14 executed, 69 up-to-dateBuild Analyzer results available上面是gradle打包后显示的最后几行能得到几个信息✅构建是成功的APK/AAR 产物正常输出可以正常编译运行⚠️ 只是警告项目中使用了已经被废弃的 Gradle API现在用 Gradle 8.14 还能跑升级到 Gradle 9.0 就会编译报错。关键点说明BUILD SUCCESSFUL最重要编译没问题。14 executed, 69 up‑to‑date增量编译大部分任务复用缓存速度正常。Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0含义build.gradle/ 第三方插件 调用了 Gradle 标记废弃的接口Gradle9 会直接移除这些接口。两个报告文件打开浏览器看详细问题problems‑report.html专门列出废弃 API、过时配置、潜在问题优先看这个Build Analyzer分析构建耗时、哪些任务慢、依赖耗时。查看完整废弃警告两种方式方式 1命令行执行./gradlew assembleDebug --warning-mode all会把每一条废弃警告打印控制台可以看到是自己写的 build 脚本还是第三方插件AGP、其他库插件产生。方式 2直接打开网页报告复制路径到浏览器打开file:///E:/xxx/build/reports/problems/problems-report.html页面会逐条展示哪个文件、哪一行、什么 API 废弃、替换方案。常见 Legado‑Max 这类老 Android 项目的废弃来源build.gradle 中老的语法compile应该替换为implementation老版本 AGP (Android Gradle Plugin) 和 Gradle 版本不完全匹配第三方插件使用旧 Gradle API插件还没适配 Gradle9部分任务、sourceSets、artifact 过时写法处理策略分两种短期现在不升级 Gradle9不用修复不影响编译打包运行只是警告继续用 Gradle8.14 即可。长期未来要升级 Gradle9执行--warning-mode all定位警告来源如果是自己脚本代码按报告提示修改为新 API如果是第三方插件产生等待插件作者更新适配 Gradle9自己无法改。小提示[Incubating] 问题报告功能本身还是孵化实验性功能报告内容可信只是 API 还不稳定不是你的项目报错。Build Analyzer 在 Android Studio 里也可以图形界面打开Build - Analyze Build。