在 IntelliJ 或 Android Studio 中默认使用 HTTP [英] Use HTTP as default in IntelliJ or Android Studio

查看:37
本文介绍了在 IntelliJ 或 Android Studio 中默认使用 HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这似乎是一个奇怪的请求(这可能有助于解释为什么没有谷歌研究帮助我找到答案)但由于一些防火墙问题,通过 HTTPS 连接到外部资源需要很长时间或完全超时.

I know this may seem like an odd request (which may help explain why no google research is helping me find the answer) but due to some firewall issues, connecting to external resources via HTTPS takes a very long time or times out entirely.

目前我的依赖项如下:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.code.gson:gson:2.3.1'
    compile 'com.mcxiaoke.volley:library:1.0.18'
}

我的错误问题如下:

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve com.mcxiaoke.volley:library:1.0.18.
     Required by:
         udacity-android-nanodegree--july2015-project1:app:unspecified
      > Could not GET 'https://jcenter.bintray.com/com/mcxiaoke/volley/library/1.0.18/library-1.0.18.pom'.
         > Connection to https://jcenter.bintray.com refused
      > Could not GET 'https://repo1.maven.org/maven2/com/mcxiaoke/volley/library/1.0.18/library-1.0.18.pom'.
         > Connection to https://repo1.maven.org refused

现在,这些错误来来去去,实际上取决于主干防火墙在 HTTPS 请求上花时间.如果您仔细查看错误,它会引用 https://jcenter.bintray.com/com/mcxiaoke/volley/library/1.0.18/library-1.0.18.pom 其中,当您去掉 https 并用 http 替换它,它揭示了同样的事情.

Now, these errors come and go and really depend on the backbone firewall taking its time on the HTTPS requests. If you look close at the error, it references https://jcenter.bintray.com/com/mcxiaoke/volley/library/1.0.18/library-1.0.18.pom which, when you strip out the https and replace it with just http it reveals the same thing.

对于需要安全的连接,由于安全/登录/等原因,HTTPS 很好,但对于下载公共库和依赖项,我如何确保 Android Studio 坚持使用常规 HTTP?

For connections that need to be secure, HTTPS due to security/logins/etc, its fine, but for downloading public libraries and dependencies, how do I ensure Android Studio sticks with regular HTTP?

推荐答案

嗯,我想我找到了答案.我只需要在我的 gradle 脚本中更新我的存储库指令以强制它使用 HTTP:

Hmm I think I found my answer. I just need to update my repositories instructions in my gradle script to force it to HTTP:

repositories {
    maven {
        url "http://repo1.maven.org/maven2"
    }
}

在它只是基于 HTTPS 的 mavenCentral() 之前

before it was just mavenCentral() which much have been HTTPS based

这篇关于在 IntelliJ 或 Android Studio 中默认使用 HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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