Flutter运行在Android上卡Running Gradle task ‘assembleDebug...

Flutter运行在Android上卡Running Gradle task ‘assembleDebug’…

是因为无法访问官方源,下面进行换源
1.修改配置文件

Flutter运行在Android上卡Running Gradle task ‘assembleDebug..._第1张图片
Flutter运行在Android上卡Running Gradle task ‘assembleDebug..._第2张图片

buildscript {
    repositories {
        // google()
        // mavenCentral()
		// 注释掉上面两个,添加下面三个
		maven { url 'https://maven.aliyun.com/repository/google' }
		maven { url 'https://maven.aliyun.com/repository/jcenter' }
		maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
    }
    dependencies {
        /* When bumping, also update ndkVersion above. */
        classpath 'com.android.tools.build:gradle:4.1.0'
    }
}




class FlutterPlugin implements Plugin {
	// 注释掉原来的,这个被墙了
    // private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";
	
	//添加新的
	private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn";

Flutter运行在Android上卡Running Gradle task ‘assembleDebug..._第3张图片

repositories {
    // google()
    // mavenCentral()
	maven { url 'https://maven.aliyun.com/repository/google' }
	maven { url 'https://maven.aliyun.com/repository/jcenter' }
	maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
    maven {
        // url "$storageUrl/download.flutter.io"
		//新加的
		url "https://storage.flutter-io.cn/download.flutter.io"
    }
}
2.修改build.gradle文件

Flutter运行在Android上卡Running Gradle task ‘assembleDebug..._第4张图片

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
    }
}

保持网络连接,重新运行即可

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