Java 在 Eclipse 中导入 Gradle 项目时对等方未通过身份验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22887829/
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
Peer not authenticated while importing Gradle project in eclipse
提问by MrTambourineMan
While I am importing gradle project in eclipse, it is giving me this error.
当我在 eclipse 中导入 gradle 项目时,它给了我这个错误。
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'test'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve de.richsource.gradle.plugins:gwt-gradle-plugin:0.3.
Required by:
:test:unspecified
> Could not GET 'https://github.com/steffenschaefer/gwt-gradle-plugin/raw/maven-repo/de/richsource/gradle/plugins/gwt-gradle-plugin/0.3/gwt-gradle-plugin-0.3.pom'.
> peer not authenticated
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I am using internet via proxy connection. If that is the issue, where to specify the proxy settings inside eclipse. In General-->Network connections, proxy settings are already there
我通过代理连接使用互联网。如果这是问题,在 eclipse 中指定代理设置的位置。在常规-->网络连接中,代理设置已经存在
Please help.
请帮忙。
采纳答案by dev2d
NOTE: Please ensure the server is trustworthy before you follow these steps.
注意:在执行这些步骤之前,请确保服务器是可信的。
If you get any other error like this:
如果您遇到任何其他错误,请执行以下操作:
Could not GET 'https://some_server.com/some/path/some.pom'.
> peer not authenticated
Then you need to import a certificate :
然后你需要导入一个证书:
- open the 'https://some_server.com/some/path/some.pom' in your favorite browser
- export the cert using the Steps to export cert from a web site
- copy the cer into
JDK_HOME/jre/lib/security
folder - open a shell and go to
JDK_HOME/jre/lib/security
folder - then import the cer into java using the
- 在您喜欢的浏览器中打开“ https://some_server.com/some/path/some.pom”
- 使用从网站导出证书的步骤导出证书
- 将cer复制到
JDK_HOME/jre/lib/security
文件夹中 - 打开外壳并转到
JDK_HOME/jre/lib/security
文件夹 - 然后使用
keytool -import -alias <the short name of the server> -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit
keytool -import -alias <the short name of the server> -file <cert_file_name_you_exported.cer> -keystore cacerts -storepass changeit
It will prompt you to import the certificate, type yes and press enter.
它将提示您导入证书,输入 yes 并按 Enter。
Then restart your eclipse and try building the project.
然后重新启动 eclipse 并尝试构建项目。
回答by xYan
After importing the certificate as suggested in the above answer, edit your gradle.propertiesfile and insert the following lines (having in mind your proxy settings):
按照上述答案中的建议导入证书后,编辑您的gradle.properties文件并插入以下几行(记住您的代理设置):
HTTPS:
HTTPS:
systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080
HTTP:
HTTP:
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
回答by Shiva Kumar SS
Change your repositories to the following in the build.gradle
在 build.gradle 中将您的存储库更改为以下内容
repositories {
maven {
url "http://repo1.maven.org/maven2"
}
}
回答by Devendra Vaja
ANSWER#2:Providing the correct fix after two Negative markings
答案#2:在两次否定标记后提供正确的修复
Make this changes to the top-level build.gradlefile.
对顶级build.gradle文件进行此更改。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
//jcenter()
jcenter {
url "http://jcenter.bintray.com/" <=THIS IS THE LINE THAT MAKES THE DIFFERENCE
}
}
}
allprojects {
repositories {
//jcenter()
jcenter {
url "http://jcenter.bintray.com/" <=THIS IS THE LINE THAT MAKES THE DIFFERENCE
}
}
}
ANSWER#1 (Although this is not accepted would like to keep this)
ANSWER#1(虽然这不被接受还是想保留这个)
If you see "peer not authenticated errors , it does not necessarily mean that the application does not hold a valid certificate. It also could mean that connections are being reset by the firewall, load balancer, or web servers. Try (re)starting the application with the Administator
privilege.
如果您看到“peer not authenticated errors ,这并不一定意味着应用程序没有有效的证书。它还可能意味着防火墙、负载平衡器或 Web 服务器正在重置连接。尝试(重新)启动具有Administator
特权的应用程序。
On Windows:
在 Windows 上:
- Ensure you have administrator privileges.
- Right Click application icon -> Select "Run as Administrator"
- 确保您具有管理员权限。
- 右键单击应用程序图标 -> 选择“以管理员身份运行”
On Linux:
在 Linux 上:
- Ensure you have root access.
- type
sudo "app execution script name"
- 确保您具有 root 访问权限。
- 类型
sudo "app execution script name"
回答by Honsen
I try to modify the repositories and import the cer to java, but both failed, then I upgrade my jdk version from 1.8.0_66 to 1.8.0_74, gradle build success.
我尝试修改存储库并将cer导入java,但都失败了,然后我将jdk版本从1.8.0_66升级到1.8.0_74,gradle构建成功。
回答by tenser
Upgrading from java7 to java8 did the trick for me.
从 java7 升级到 java8 对我有用。
回答by Stefan Brendle
I'm using android studio 1.51 with Linux (Ubuntu 14.04 LTS) and got the same error message:
我在 Linux (Ubuntu 14.04 LTS) 上使用 android studio 1.51 并收到相同的错误消息:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not resolve com.github.PhilJay:MPAndroidChart:v2.1.6.
Required by:
dbtraining-dbtrainingandroidapp-517de26197d8:app:unspecified
> Could not resolve com.github.PhilJay:MPAndroidChart:v2.1.6.
> Could not get resource 'https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.pom'.
> Could not GET 'https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.pom'.
> peer not authenticated
I tried to move maven { url "https://jitpack.io" }
, set it to http instead of https, activated the "accept non-trusted certificates automatically", added the ssl certificate manually ... but still no luck.
我试图移动maven { url "https://jitpack.io" }
,将其设置为 http 而不是 https,激活“自动接受不受信任的证书”,手动添加 ssl 证书......但仍然没有运气。
The solution was to switch from OpenJDK 7 to Oracle JDK 8:
解决方案是从 OpenJDK 7 切换到 Oracle JDK 8:
- Downloaded the files for the JDK from Oracle, I took the tarball
(jdk-8u101-linux-x64.tar.gz) - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html - Extract the files. The folder name is
jdk1.8.0_101
- Now switch to the directory
/opt/
(nautilus hotkey: CTRL+L) and create a new folder "Oracle_Java". Maybe this requires root access, so open nautilus from the terimal withsudo nautilus
- Copy the folder
jdk1.8.0_101
to/opt/Oracle_Java
Follow the instructions from https://wiki.ubuntuusers.de/Java/Installation/Oracle_Java/Java_8/#Java-8-JDK: Do not forget to replace the version placeholder in the path with your version
- 从 Oracle 下载了 JDK 的文件,我拿了 tarball
(jdk-8u101-linux-x64.tar.gz) - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151 .html - 提取文件。文件夹名称是
jdk1.8.0_101
- 现在切换到目录
/opt/
(nautilus 热键:CTRL+L)并创建一个新文件夹“Oracle_Java”。也许这需要root访问权限,所以从终端打开nautilussudo nautilus
- 将文件夹复制
jdk1.8.0_101
到https://wiki.ubuntuusers.de/Java/Installation/Oracle_Java/Java_8/#Java-8-JDK 中/opt/Oracle_Java
的说明 :不要忘记将路径中的版本占位符替换为您的版本
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws" 1 sudo update-alternatives --install "/usr/bin/jar" "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar" 1 sudo update-alternatives --set "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java" sudo update-alternatives --set "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac" sudo update-alternatives --set "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws" sudo update-alternatives --set "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar"
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws" 1 sudo update-alternatives --install "/usr/bin/jar" "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar" 1 sudo update-alternatives --set "java" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/java" sudo update-alternatives --set "javac" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javac" sudo update-alternatives --set "javaws" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/javaws" sudo update-alternatives --set "jar" "/opt/Oracle_Java/jdk1.8.0_VERSION/bin/jar"
- You can check in the terminal with the command
java -version
if your installation was successful. - Now to back to android studio and open the
project structure
window by pressing the hotkey CTRL+SHIFT+ALT+S and go toSDK Location
. Here you can set the path to JDK, for example/opt/Oracle_Java/jdk1.8.0_101
java -version
如果安装成功,您可以使用命令在终端中检查。- 现在返回 android studio 并
project structure
通过按热键 CTRL+SHIFT+ALT+S打开窗口并转到SDK Location
. 这里可以设置JDK的路径,例如/opt/Oracle_Java/jdk1.8.0_101
That's it! :)
就是这样!:)
回答by Brod
I had this error and it was happening because of a VPN proxy issue. I disabled my VPN client and everything worked fine after. I used this command (on a Mac):
我遇到了这个错误,它是由于 VPN 代理问题而发生的。我禁用了我的 VPN 客户端,之后一切正常。我使用了这个命令(在 Mac 上):
sudo /opt/cisco/anyconnect/bin/acwebsecagent -disablesvc -websecurity
sudo /opt/cisco/anyconnect/bin/acwebsecagent -disablesvc -websecurity
回答by Calahad
Upgrading to the latest version of gradle fixed this for me.
升级到最新版本的 gradle 为我解决了这个问题。
- update
distributionUrl
ingradle-wrapper.properties
to use the latest version. - update
gradleVersion
inbuild.gradle
to match that version.
- 更新
distributionUrl
在gradle-wrapper.properties
使用最新版本。 - 更新
gradleVersion
以build.gradle
匹配该版本。
回答by Marian Klühspies
I had a strange case where I had to change the order of jcenter and maven to get rid of the error
我有一个奇怪的例子,我不得不改变 jcenter 和 maven 的顺序来摆脱错误
Not working
不工作
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
maven { url "https://jitpack.io" }
}
}
Working
在职的
allprojects {
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
maven { url "https://jitpack.io" }
}
}