简体   繁体   中英

gradle sync error android studio

I was trying to create some android sample app using android studio and I came across a gradle sync error.

It says unknown host for jcenter.bintray.com and configure proxy.

But when I try to access it using browser url is accessible. I also tried to check connection in android studio > setting > system settings > http proxy > check connection.

It shows connection successful. So the error occurs only when it builds. what could be the reason?

build.gradle

buildscript {
repositories {
    jcenter { url "http://jcenter.bintray.com/" }
}

dependencies {
    classpath 'com.android.tools.build:gradle:2.2.1'
}
}

allprojects {
}

This happens because the android studio could not able to fetch the dependencies from the repository.

Try updating android studio to newer version , along with deactivating offline mode got it to work.

Remove testCompile 'junit:junit:4.12' from build.gradle file, If you are not using unit test.

If you need test case, Set up proxy settings(file->settings->appearance & behaviour ->system settings->http proxy ) , if you are behind proxy.

and add below repository in build.gradle,

repositories {
    maven { url 'http://repo1.maven.org/maven2' }
    jcenter { url "http://jcenter.bintray.com/" }
}

如果是互联网访问问题,请在 android studio 首选项中检查和配置代理 url,并使用端口设置手动代理 url。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM