我刚刚将 cordova 版本从 4.0 更新到 5.1,并且在创建项目时一切正常。但是当我发出 cordova build 命令时,我收到了以下错误。
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:1.0.0+.
Required by:
:android:unspecified
> Failed to list versions for com.android.tools.build:gradle.
> Unable to load Maven meta-data from https://repo1.maven.org/maven2/co
m/android/tools/build/gradle/maven-metadata.xml.
> Could not GET 'https://repo1.maven.org/maven2/com/android/tools/bu
ild/gradle/maven-metadata.xml'.
> peer not authenticated
经过两天的痛苦,我知道它是由于 gradle 导致的,我下载了它并将其添加到环境变量中。当我转到 cordova 项目中的 android 文件夹并给出 gradle init 命令时,我也会收到此错误。不知道这可能是什么原因。我仍在使用 eclipse 而不是 android studio,这也是一个原因吗?
最佳答案
这是一个 Java SSL 连接错误,您需要将适当的 SSL 证书添加到 Java keystore 以供 Java 接受连接。
Step 1: Download the certificate
With Mozilla Firefox:
- Go to https:// repo1.maven.org (remove the space).
- Click on the green padlock at the left of the address bar.
- Click on Details.
- Click on View certificate.
- Click on Details.
- Click on Export.
- Export file to "X.509 Certificate (PEM) (*.crt; *.pem)"
Step 2: Add the certificate to default Java Keystore
sudo keytool -import -alias MavenRepo -keystore $JAVA_HOME/jre/lib/security/cacerts -file /PATH/TO/YOUR/EXPORTED/FILE.crt
Your
$JAVA_HOME
variable should be declared in your .bashrc file, so you can use this command just replacing the/PATH/TO/YOUR/EXPORTED/FILE
parameter.PS: The default password of Java Keystore is:
changeit
From: https://github.com/meteor/meteor/issues/6362#issuecomment-189852511
关于android - 创建 cordova 项目时出现 gradle 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30995348/