Flutter packaging solves the infinite loop problem of Running Gradle task 'assembleRelease'...

In fact, in the final analysis, accessing Google sources in China is too slow or times out, so there are two options

Solution 1: Let yourself have smooth access to Google and understand everything
Option 2: Change the mirror address. A total of 3 places need to be changed.

1-Change the flutter/packages/flutter_tools/gradle/flutter.gradle file

Replace Google and Maven Central with Alibaba Cloud images

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

2-更改flutter/packages/flutter_tools/gradle/resolve_dependencies.gradle文件

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

3-Change the android/build.gradle file

同上
buildscript {
    ext.kotlin_version = '1.6.10'
    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' }
    }

}

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


    }
}

Guess you like

Origin blog.csdn.net/wuguidian1114/article/details/128712118