flutter项目运行时一直卡在Running Gradle task ‘assembleDebug‘解决办法

1.修改项目中的android/build.gradle,将google(),mavenCentral()替换为下面的代码

bash 复制代码
 maven { url 'https://maven.aliyun.com/repository/central/' }
 maven { url 'https://maven.aliyun.com/repository/public/' }
 maven { url 'https://maven.aliyun.com/repository/google/' }
 maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }

2.找到flutter的安装路径,找到packages\flutter_tools\gradle下的flutter.gradle文件,找到buildscript对象,对里面的repositories内容进行修改,换成以下代码

bash 复制代码
buildscript {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/central/' }
        maven { url 'https://maven.aliyun.com/repository/public/' }
        maven { url 'https://maven.aliyun.com/repository/google/' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }

    dependencies {
        /** When bumping, also update ndkVersion above, as well as the Android Gradle Plugin
         * version in ../lib/src/android/gradle_utils.dart.
         */
        classpath 'com.android.tools.build:gradle:7.3.0'
    }
}

3.依然在flutter.gradle文件中使用"ctrl+F"搜索DEFAULT_MAVEN_HOST,修改为以下代码

bash 复制代码
private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn";

(本文的flutter版本为Flutter 3.10.6)

参考:

flutter运行一直显示Running Gradle task 'assembleDebug'.

相关推荐
jcLee955 小时前
Flutter/Dart:使用日志模块Logger Easier
flutter·log4j·dart·logger
tmacfrank6 小时前
Flutter 异步编程简述
flutter
tmacfrank6 小时前
Flutter 基础知识总结
flutter
叫我菜菜就好7 小时前
【Flutter_Web】Flutter编译Web第三篇(网络请求篇):dio如何改造方法,变成web之后数据如何处理
前端·网络·flutter
AiFlutter11 小时前
Flutter-底部分享弹窗(showModalBottomSheet)
java·前端·flutter
m0_748247802 天前
Flutter Intl包使用指南:实现国际化和本地化
前端·javascript·flutter
迷雾漫步者2 天前
Flutter组件————PageView
flutter·跨平台·dart
迷雾漫步者2 天前
Flutter组件————FloatingActionButton
前端·flutter·dart
coder_pig2 天前
📝小记:Ubuntu 部署 Jenkins 打包 Flutter APK
flutter·ubuntu·jenkins
捡芝麻丢西瓜2 天前
flutter自学笔记5- dart 编码规范
flutter·dart