Flutter 、Android 的 gradle配置,使用国内的镜像 让gradle构建下载加速

gradle配置,由于gladle默认的maven仓库是在国外的 国内访问特别慢 甚至超时,这里使用国内阿里的镜像 让gradle构建下载加速 让构造飞起来
在 GRALDE_HOME/init目录下 创建 init.gradle文件,复制如下:

allprojects{
	repositories {
		def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
		def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
		def ALIYUN_GOOGLE_URL  = 'http://maven.aliyun.com/repository/google'
		def ALIYUN_GRADLE_PLUGIN_URL  = '`http://maven.aliyun.com/repository/gradle-plugin`'
		all { ArtifactRepository repo ->
		if(repo instanceof MavenArtifactRepository){

			def url = repo.url.toString()

			if (url.startsWith('https://repo1.maven.org/maven2')) {
				project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
				remove repo
			}
			if (url.startsWith('https://jcenter.bintray.com/')) {
				project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
				remove repo
			}
			if (url.startsWith('https://maven.google.com/')) {
				project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL  
				remove repo
			}
			if (url.startsWith('https://plugins.gradle.org/m2/')) {
				project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL  
				remove repo
			}

		}
	}
		maven {
			url ALIYUN_REPOSITORY_URL
			url ALIYUN_JCENTER_URL
			url ALIYUN_GOOGLE_URL  
			url ALIYUN_GRADLE_PLUGIN_URL  
		}
	}
}

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