gradle project sync failed.Basic functionality问题的解决

在安装AS之后总会出现gradle project sync failed.Basic functionality 的问题:




这个问题解决之后会出现    Unknown host 'jcenter.bintray.com  报错,接着要解决这个问题:

使用开源中国的maven库:

阿里云的:http://maven.aliyun.com/nexus/content/groups/public/

在项目根目录下的build.gradle中添加如下(把文件中的代码修改为一下代码即可,对比添加自己代码中没有的部分):

buildscript {

    repositories {
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'


        // 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()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

同时,放在jcenter()前,保证先访问maven中的链接。

问题解决!

 Unknown host 'jcenter.bintray.com  问题的解决方法参考自:https://blog.csdn.net/AndCo/article/details/80915023

猜你喜欢

转载自blog.csdn.net/qq_36418170/article/details/81063152
今日推荐