赞
踩
程序运行时会卡在Running Gradle task 'assembleDebug'...
如下提示信息
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
此时Gradle正在下载gradle构建工具以及相关依赖库,由于官方gradle默认配置的依赖下载服务器处于国外,国内用户访问非常缓慢,常常一个依赖下载就要花半天时间,好在国内有阿里、清华等镜像源,我们可以配置镜像代理加快依赖的下载
进入项目目录的android/build.gradle
,修改为如下,注意不要注释掉google()
和mavenCentral()
,因为部分依赖可能镜像源没有,gradle
找不到的话会报错
buildscript { ext.kotlin_version = '1.7.10' repositories { maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/spring/'} maven { url 'https://maven.aliyun.com/repository/google/'} maven { url 'https://maven.aliyun.com/repository/gradle-plugin/'} maven { url 'https://maven.aliyun.com/repository/spring-plugin/'} maven { url 'https://maven.aliyun.com/repository/grails-core/'} maven { url 'https://maven.aliyun.com/repository/apache-snapshots/'} google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:7.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/spring/'} maven { url 'https://maven.aliyun.com/repository/google/'} maven { url 'https://maven.aliyun.com/repository/gradle-plugin/'} maven { url 'https://maven.aliyun.com/repository/spring-plugin/'} maven { url 'https://maven.aliyun.com/repository/grails-core/'} maven { url 'https://maven.aliyun.com/repository/apache-snapshots/'} google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } tasks.register("clean", Delete) { delete rootProject.buildDir }
进入android/wrapper/gradle-wrapper.properties
文件
distributionUrl
的值用镜像源替代,需要注意的是后面的gradle版本需要和替换镜像源前的gradle
版本一致
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-all.zip
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。