运行Flutter时候出现如下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
.................
解决办法:
1、在flutter项目下的 android > build.gradle文件修改repositories,注释google()、jcenter(),添加阿里地址。
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' }mavenLocal()mavenCentral()}dependencies {classpath 'com.android.tools.build:gradle:3.5.0'classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"}
}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' }mavenLocal()mavenCentral()}
}
2、在flutter sdk 目录下,找到packages\flutter_tools\gradle\flutter.gradle,在repositories中注释google()、jcenter(),添加阿里地址。
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' }mavenLocal()mavenCentral()}dependencies {classpath 'com.android.tools.build:gradle:3.5.0'}
}