按照Flutter步骤安装,新建了一个DEMO,Debug 无法通过,抛出类似如下的错误信息,
* Where: Build file '.../android/app/build.gradle' line: 25
原因是jcenter google库无法访问,被强了,即使有VPN等等,也无法访问
解决方法1:修改build.gradle,注释掉jcenter(),google()。使用阿里的镜像。
buildscript {
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' }
}
}
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' }
}
}
第二步:找到fluttersdk目录 进入如下目录
Flutter -> packages -> flutter_tools -> gradle
找到 flutter.gradle 文件 , 把jcenter注释掉,替换阿里的镜像
buildscript {
repositories {
//jcenter()
//maven {
// url 'https://dl.google.com/dl/android/maven2'
//}
maven{
url 'https://maven.aliyun.com/repository/jcenter'
}
maven{
url 'http://maven.aliyun.com/nexus/content/groups/public'
}
}
}