After creating a new Flutter project Android project, click Run and an error will appear!
This is caused by the inaccessibility of the mirror site! It only needs to be modified to a domestically accessible site.
Step 1: Modify build.gradle in the Android directory of the project
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
// google() 无法访问,使用阿里镜像
// jcenter()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
maven { url 'http://download.flutter.io'}
}
allprojects {
repositories {
// google()
// jcenter()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
}
Step 2: Modify flutter.gradle in flutter SDK
path: flutter\packages\flutter_tools\gradle\flutter.gradle
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}