Java Android Studio / Intellij、Gradle 错误:原因:对等方未通过身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27206040/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 03:58:35  来源:igfitidea点击:

Android Studio / Intellij, Gradle Error:Cause: peer not authenticated

javaandroidsslintellij-ideagradle

提问by NathanielB

Having a fight with IntelliJ at the moment. The darn thing won't download Gradle 2.1

目前正在与 IntelliJ 打架。该死的东西不会下载Gradle 2.1

I have an Android project hosted on GitHub, which I have cloned to my laptop. I have got working SSL certificates, I know this as I can download SDK software from google using SSL, and I can also download Gradle 1.12. The message I have received from IntelliJ is the rather infamous Error:Cause: peer not authenticatederror.

我在 GitHub 上托管了一个 Android 项目,我已将其克隆到我的笔记本电脑上。我有可用的 SSL 证书,我知道这一点,因为我可以使用 SSL 从谷歌下载 SDK 软件,我也可以下载 Gradle 1.12。我从 IntelliJ 收到的消息是相当臭名昭著的Error:Cause: peer not authenticated错误。

From the terminal running IntelliJ I get this:

从运行 IntelliJ 的终端我得到这个:

    * What went wrong:
A problem occurred configuring root project 'SomeAndroidProject'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:0.13.0.
     Required by:
         :SomeAndroidProject:unspecified
      > Could not HEAD 'https://jcenter.bintray.com/com/android/tools/build/gradle/0.13.0/gradle-0.13.0.pom'.
         > peer not authenticated

I have search far and wide across the internet, with no avail. Please help me wise SO guru's!

我在互联网上进行了广泛的搜索,但无济于事。请帮助我明智的SO大师的!

采纳答案by Atilla Ozgur

Change your repositories syntax in build.gradle as following. See following question.

如下更改 build.gradle 中的存储库语法。请参阅以下问题

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

回答by BzH

you should import the certificate:

您应该导入证书:

First of all download the certificate (.cer) from this url, Help is here

首先从这个网址下载证书(.cer),帮助在这里

Copy it to the path JDK_HOME/jre/lib/security

复制到路径 JDK_HOME/jre/lib/security

Then with command prompt targeted to above location, run the following command:

然后使用针对上述位置的命令提示符,运行以下命令:

keytool -import -alias git -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit

Type yes if it prompts for approval, after that open the desired IDEA and have fun :)

如果提示批准,请输入 yes,然后打开所需的 IDEA 并玩得开心:)

If this doesn't help, try importing the certificate to JRE/lib/security/cacerts, It's totally depend on the build path of the IDEA you are using

如果这没有帮助,请尝试将证书导入到JRE/lib/security/cacerts,这完全取决于您使用的 IDEA 的构建路径

回答by GR Envoy

When I updated to Android Studio 1.0 I found that I need to update to use 1.0.0 version of gradle.

当我更新到 Android Studio 1.0 时,我发现我需要更新以使用 1.0.0 版本的 gradle。

Inside of the build.gradle file I had

在 build.gradle 文件里面我有

  dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0-rc2'

I changed it to remove the "-rc2"

我将其更改为删除“-rc2”

  dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'

回答by Felix Shin

yeah I experienced exactly same situation It is not easy, but now I'm clear

是的,我经历了完全相同的情况这并不容易,但现在我很清楚

I changed the build.gradle located in project forlder, not in app folder

我更改了位于项目文件夹中的 build.gradle,而不是在 app 文件夹中

I changed as below

我改变如下

repositories {
    jcenter 
    { 
        url 'http://jcenter.bintray.com' 
    } 
}

instead of

代替

repositories {
    jacenter()
}

回答by Levi Saturnino

"Error:Cause: peer not authenticated."

“错误:原因:对等方未通过身份验证。”

As this occurs I using Ubuntu: When I changed version on android studio 2.0 9 preview beta 1.

发生这种情况时,我使用 Ubuntu:当我在 android studio 2.0 9 preview beta 1 上更改版本时。

How do I fix my gradle.

我该如何修复我的 gradle.

Simply created a new project in android studio and then went in and saw build.grandle version gradle in my case: ?

简单地在 android studio 中创建了一个新项目,然后进入并在我的情况下看到 build.grandle 版本 gradle:?

 dependencies {
???????? classpath 'com.android.tools.build:gradle:2.0.0-beta1'
???? }

and replace in my project.

并在我的项目中替换。

I hope it helps others.

我希望它可以帮助其他人。

回答by Levi Saturnino

I've fixed this issue by adding the following to my build.gradle:

我已通过将以下内容添加到我的 build.gradle 中来解决此问题:

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

Once done, try syncing and rebuilding your project. Hope this was helpful.

完成后,尝试同步和重建您的项目。希望这是有帮助的。

回答by SherloxTV

Like BzH :

像 BzH :

This is a Java SSL connection error I solved on Github here.

这是一个Java SSL连接的错误,我解决了在Github这里

You need to add the appropriate SSL certificate to the java keystore for java accept the connection.

您需要将适当的 SSL 证书添加到 java 密钥库,以便 java 接受连接。

Work fine :)

工作正常:)

回答by Serg

in case when there are some problems with internet try to add a line

如果互联网出现问题,请尝试添加一行

54.231.14.232 s3.amazonaws.com

to your /etc/hosts (..\Windows\System32\drivers\etc\hosts)

给你的 /etc/hosts (..\Windows\System32\drivers\etc\hosts)

回答by SKallmann

I've fixed this issue by adding the following to me build.gradle:

我通过在 build.gradle 中添加以下内容解决了这个问题:

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

Once done, try syncing and rebuilding your project. Hope this was helpful.

完成后,尝试同步和重建您的项目。希望这是有帮助的。