当前位置:   article > 正文

(原创)Flutter开发问题:项目启动一直卡在Running Gradle task ‘assembleDebug‘_flutter首次新建项目后 跑不起来

flutter首次新建项目后 跑不起来

问题描述

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

解决办法

步骤1

修改android\build.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.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
 }

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38

步骤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'
     }
 }

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

步骤3

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

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

修改为

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

步骤4

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

	maven {
        url "http://download.flutter.io"
    }
  • 1
  • 2
  • 3

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/613595
推荐阅读
相关标签
  

闽ICP备14008679号