(原创)Flutter开发问题:项目启动一直卡在Running Gradle task ‘assembleDebug‘

问题描述

按照flutter官网步骤安装Flutter SDK、Android studio等,
在创建第一个flutter项目后run的过程一直是Running Gradle task ‘assembleDebug’…
针对这个问题,现在给出解决方法

解决办法

步骤1

修改android\build.gradle文件
(原创)Flutter开发问题:项目启动一直卡在Running Gradle task ‘assembleDebug‘_第1张图片

buildscript {
     repositories {
         //修改的地方
        //google()
         //jcenter()
         maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'https://maven.aliyun.com/repository/jcenter' }
         maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
     }

    dependencies {
         classpath 'com.android.tools.build:gradle:3.2.1'
     }
 }

allprojects {
     repositories {
         //修改的地方
        //google()
         //jcenter()
         maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'https://maven.aliyun.com/repository/jcenter' }
         maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
     }
 }

rootProject.buildDir = '../build'
 subprojects {
     project.buildDir = "${rootProject.buildDir}/${project.name}"
 }
 subprojects {
     project.evaluationDependsOn(':app')
 }

task clean(type: Delete) {
     delete rootProject.buildDir
 }

步骤2

修改Flutter的配置文件, 该文件在FlutterSDK安装目录/packages/flutter_tools/gradle/flutter.gradle

buildscript {
     repositories {
         //修改的地方
        //google()
         //jcenter()
         maven { url 'https://maven.aliyun.com/repository/google' }
         maven { url 'https://maven.aliyun.com/repository/jcenter' }
         maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:3.5.0'
     }
 }

步骤3

继续修改 FlutterSDK安装目录/packages/flutter_tools/gradle/flutter.gradle文件

private static final String MAVEN_REPO = "https://storage.googleapis.com/download.flutter.io";

修改为

private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn";

步骤4

修改FlutterSDK安装目录/packages/flutter_tools/gradle/resolve_dependencies.gradle文件
第20行的maven为:

	maven {
        url "http://download.flutter.io"
    }

然后重启Android Studio,再次运行就可以了

你可能感兴趣的:(android,flutter)