Android Studio flutter项目运行、打包时间太长

Android Studio:Android Studio Meerkat Feature Drop | 2024.3.2 Patch 1

flutter Sdk:3.29.3

系统:windows

flutter sdk从2.10.5升级到3.29.3,但是Flutter 3.16开始新增了使用 Gradle声明式 plugins {} 块,gradle文件配置方式改变了。而国内的阿里云、华为云等镜像仓库的更新并不是与google()仓库同步的。

所以注释掉google()只引用国内的镜像仓库运行就无法编译通过

例如异常:

复制代码
从 maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'xxxxxx' }
plugin [ id "com.android.application" version "8.7.2" apply false ] 无法找到

编译时依次从项目配置的仓库中都无法查询到com.android.application" version "8.7.2" apply false 。因为国内的镜像仓库中没有更新它。

所以从google()拉取只能等待(更新flutter sdk后第一次运行成功等待了43分钟)

优化:

1.更改Android studio内存,我直接改到最大

2.gradle.propertes文件中配置

再运行,依然会很慢但是有一点提升。

3.android\gradlew.bat文件中GradleWrapperMain末尾增加--offline,设置为离线模式

前提是运行成功过在本地有了缓存,才能在设置离线模式后运行成功,此时运行时长缩短到2-3分钟。

打包同样也需要成功过,才能在离线模式下打包成功,此时打包时长会缩短较多。

相关推荐
周杰伦的稻香2 小时前
MySQL中的空间碎片率计算分析
android·数据库·mysql
zhifanxu2 小时前
Flutter开发学习汇总
flutter
用户093 小时前
MVI架构如何改变Android开发模式
android·面试·kotlin
梦终剧3 小时前
【Android之路】.sp和界面层次结构
android
2501_916008893 小时前
iOS 26 软件性能测试全流程,启动渲染资源压力对比与优化策略
android·macos·ios·小程序·uni-app·cocoa·iphone
zh_xuan4 小时前
Android Handler源码阅读
android
雪饼android之路4 小时前
【Android】 android suspend/resume总结(3)
android·linux
00后程序员张4 小时前
iOS 26 兼容测试实战,机型兼容、SwiftUI 兼容性改动
android·ios·小程序·uni-app·swiftui·cocoa·iphone
molong9315 小时前
Android 应用配置跳转微信小程序
android·微信小程序·小程序