且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法解析com.android.support:appcompat-v7:26.1.0. =>配置HTTP代理

更新时间:2022-11-17 13:23:19

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

I had the same error. Tried a lot of *** 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>