无法解析com.android.support:appcompat-v7:26.1.0. =>配置HTTP代理 [英] Could not resolve com.android.support:appcompat-v7:26.1.0. => configure HTTP proxy

查看:86
本文介绍了无法解析com.android.support:appcompat-v7:26.1.0. =>配置HTTP代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了Android Studio 3.0,并开始遵循构建我的第一个应用教程.但是Gradle抛出了以下错误:

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

无法解析com.android.support:appcompat-v7:26.1.0.

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

我在SO上搜索了类似的问题,例如 this

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

最终我发现我正在使用Android Studio代理:

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

要解决该错误,我还必须通过将以下行添加到gradle.properties文件来实现Gradle代理:

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

将以上语句添加到gradle.properties后,该错误已得到解决.请注意,两者 HTTPHTTPS代理都需要添加到Gradle属性中

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

推荐答案

我有相同的错误.尝试了很多stackoverflow链接,但是直到这个链接都没有帮助.我的问题是由于gradle.properties文件中没有https代理设置.我包括了它,它起作用了.

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.

对于android studio 3,在项目的build.gradle文件中,您具有以下内容:

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

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

jcenter()运行于https之上,因此,如果您正在使用https代理的网络(在大多数情况下为公司网络)中构建,却忘记将其包含在gradle.properties文件中,那么您很可能会遇到问题.您可能会觉得gradle的行为很奇怪,但事实并非如此.它只是缺少正确的网络配置.即使是离线构建设置也无法使用,因为在您首次使用最新的Android Studio构建应用程序时,仍然需要jcenter()来下载文件.

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.

我将我的https代理设置包括在gradle.properties中,如下所示:

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>

这篇关于无法解析com.android.support:appcompat-v7:26.1.0. =&gt;配置HTTP代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆