Flutter新建项目运行报错Could not determine the dependencies of task ‘:app:compileDebugJavaWithJavac‘.

  • Post author:
  • Post category:java




Flutter新建项目运行报错,错误如下

在这里插入图片描述

这个问题是Google被墙了,需要配置阿里云镜像



第一步:修改android目录下的build.gradle文件中的

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'}
    }

    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' }
        maven { url 'http://download.flutter.io'}
    }
}



第二步:修改flutter sdk下的flutter.gradle文件,具体目录是flutter\packages\flutter_tools\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'
    }
}



版权声明:本文为ssq236811原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。