flutter Gradle Sync同步失败的解决方法

发布于 3 年前 作者 phonegap100 2134 次浏览 最后一次编辑是 3 年前 来自 分享

使用在flutter时候android studio第一次导入项目会出现Gradle Sync同步失败的问题如何解决?

android studio Gradle Sync同步失败的主要原因就是网络问题

解决方案 使用阿里云镜像

只需要添加相应的url地址就可以下载;打开项目build gradle文件。

buildscript {
    
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        
 
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
 
allprojects {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }
}

在flutter项目中找到 platforms\android\build.gradle 然后加入红色框框里面的url ,如下图 image.png

配置完成后重新点击 file->sync Project With Gradle File

如果上面方法还是没法解决的话可以百度或者谷歌搜索:android Gradle Sync同步失败的解决方法

回到顶部