当前位置:   article > 正文

Flutter项目启动一直卡在Running Gradle task ‘assembleDebug‘问题解决_flutter running gradle task 'assembledebug'...

flutter running gradle task 'assembledebug'...

问题描述:按照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

2、修改Flutter的配置文件, 该文件在Flutter安装目录/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

按照网上的一些说法,此时重新run项目即可解决,但我的仍然报错,继续修改配置文件:
3、继续修改 Flutter安装目录/packages/flutter_tools/gradle/flutter.gradle文件

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

修改为

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

也有的修改为

private static final String MAVEN_REPO      = "https://mirrors.tuna.tsinghua.edu.cn/flutter/download.flutter.io";
  • 1

private static final String MAVEN_REPO      = "http://download.flutter.io"; 
  • 1

供参考

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

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

此时重新run项目,成功运行。
在这里插入图片描述
(另外网上有另一种解决方法,没有尝试过)

仅此记录,仅供参考
End

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

闽ICP备14008679号