Flutter更改国内镜像资源

一修改项目中镜像资源

在项目中找到build.gradle文件,修改内容如下图所示
Flutter更改国内镜像资源_第1张图片
Flutter更改国内镜像资源_第2张图片
方便粘贴:

buildscript {
    ext.kotlin_version = '1.7.10'
    repositories {
        maven {
            url 'https://maven.aliyun.com/repository/public/'
        }
        maven {
            url 'https://maven.aliyun.com/repository/public'
        }
        maven {
            url 'https://maven.aliyun.com/repository/gradle-plugin'
        }
        maven {
            url 'https://maven.aliyun.com/repository/google'
        }
        maven {
            url 'https://maven.aliyun.com/repository/central'
        }
        mavenLocal()
        mavenCentral()


    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.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/gradle-plugin'
        }
        maven {
            url 'https://maven.aliyun.com/repository/google'
        }
        maven {
            url 'https://maven.aliyun.com/repository/central'
        }
        mavenLocal()
        mavenCentral()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

二、修改flutterSDK中的镜像资源url

找到自己的flutterSDK安装目录
例如:E:\Program Files\flutter\packages\flutter_tools\gradle
做如下修改
Flutter更改国内镜像资源_第3张图片
Flutter更改国内镜像资源_第4张图片
方便粘贴:

buildscript {
    repositories {
        
           maven {
            url 'https://maven.aliyun.com/repository/public/'
        }
        maven {
            url 'https://maven.aliyun.com/repository/public'
        }
        maven {
            url 'https://maven.aliyun.com/repository/gradle-plugin'
        }
        maven {
            url 'https://maven.aliyun.com/repository/google'
        }
        maven {
            url 'https://maven.aliyun.com/repository/central'
        }
        // google()
        // mavenCentral()
    }
    dependencies {
        /* When bumping, also update ndkVersion above. */
        classpath 'com.android.tools.build:gradle:7.3.0'
    }
}

如果镜像资源不能用了怎么办?

来这里找呗阿里云云效 Maven

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