Could not resolve com.android.support:appcompat-v7:26.1.0. => configure HTTP proxy

自作多情 提交于 2019-12-01 05:40:10

问题


I downloaded Android Studio 3.0 and I started following along building my first app tutorial. But Gradle threw errors like:

Could not resolve com.android.support:appcompat-v7:26.1.0.

I searched on SO for similar problems like this and that, but none of them helps me.


Eventually I figured out that I'm using a proxy for Android Studio:

To resolve the error, I have to implement the proxy for Gradle too, by adding these lines to gradle.properties file:

systemProp.http.proxyHost=127.0.0.1
systemProp.http.nonProxyHosts=localhost, 127.0.0.1
org.gradle.jvmargs=-Xmx1536m
systemProp.http.proxyPort=8118

systemProp.https.proxyHost=127.0.0.1
systemProp.https.nonProxyHosts=localhost, 127.0.0.1
systemProp.https.proxyPort=8118

After adding the above statements to gradle.properties, the error got resolved. Note that both HTTP and HTTPS proxies need to be added to Gradle properties


回答1:


I had the same error. Tried a lot of stackoverflow links but none of them helped until this one. The problem in my case was due to https proxy settings which were not there in the gradle.properties file. I included it and it worked.

For android studio 3, inside build.gradle file of your project you have this:

allprojects {
    repositories {
        jcenter()
        google()
    }
}

The jcenter() runs over https and hence if you are building in a network(in most cases company network) which uses https proxy, and you forgot to include it in your gradle.properties file, then you are likely to face the issue. You may feel that gradle is behaving weird but its not. Its only missing the proper network configuration. Even offline build settings wont work since it still needs jcenter() to download files for the first time you are building an app in latest Android Studio.

I included my https proxy settings in gradle.properties like this:

systemProp.https.proxyHost=<proxy server address>
systemProp.https.nonProxyHosts=localhost, 127.0.0.1
systemProp.https.proxyPort=<port number>


来源:https://stackoverflow.com/questions/47124746/could-not-resolve-com-android-supportappcompat-v726-1-0-configure-http-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!