[Flutter] 运行Flutter项目一直卡在--Running Gradle task 'assembleDebug'...

问题现象:

运行Flutter项目后, 一直卡在:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...

原因: 因为Gradle的Maven仓库是在国外, 我们可以使用阿里云的镜像地址~

1. 打开Flutter SDK的安装目录, 找到Flutter的配置文件

    文件路径为: Flutter安装目录/packages/flutter_tools/gradle/flutter.gradle

将repositories里的google()和jcenter()注释掉, 换成阿里仓库的maven地址: 

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

2. 打开Flutter项目中的android/build.gradle文件, 跟步骤1一样, 将google()和jcenter()注释, 换成阿里maven仓库

buildscript {
    ext.kotlin_version = '1.3.50'
    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'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

3. 完成以上修改后重新运行项目即可

你可能感兴趣的:(flutter,跨平台)