android - 创建 cordova 项目时出现 gradle 错误

标签 android eclipse cordova gradle

我刚刚将 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:

  1. Go to https:// repo1.maven.org (remove the space).
  2. Click on the green padlock at the left of the address bar.
  3. Click on Details.
  4. Click on View certificate.
  5. Click on Details.
  6. Click on Export.
  7. 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/

相关文章:

java - 'java.lang.AssertionError : assertion failed' Error while starting Scala-IDE(Eclipse)

eclipse - 在哪里托管 Eclipse 更新站点

eclipse - 在 Eclipse 中,如何以编程方式在类路径条目上设置 JavaDoc URL?

android - 通过 PhoneGap Build 从 Android 4.x 应用程序的图像映射区域中删除突出显示

安卓工作室 : "Error initializing ADB: Android Debug Bridge not found"

Android imageview onclick 获取多个 View

android - 如何将 TextView 拖动到正确的目标其他 TextView

android - 如何从自定义 View 访问宿主 fragment 的生命周期范围?

android - Cordova:无法添加 Android 平台,出现 EACCES 错误

ios - ionic 构建 iOS SDK 8.4