在创建cordova项目时遇到错误 [英] getting gradle error while creating cordova project

查看:185
本文介绍了在创建cordova项目时遇到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将cordova版本从4.0更新到5.1,并且在创建项目中一切都很好。但是一旦我命令了 cordova build ,就会出现错误。

 根项目android。 
>无法解析配置':classpath'的所有依赖项。
>无法解析com.android.tools.build:gradle:1.0.0+。
必填项:
:android:unspecified
>无法列出com.android.tools.build:gradle的版本。
>无法从https://repo1.maven.org/maven2/co
m / android / tools / build / gradle / maven-metadata.xml加载Maven元数据。
>无法GET'https://repo1.maven.org/maven2/com/android/tools/bu
ild / gradle / maven-metadata.xml'。
>对等体未认证

经过2天的痛苦,我来了解这是因为毕业,我下载并添加它也在环境变量中。当我去到cordova项目中的android文件夹并给出 gradle init 的命令时,我也得到这个错误。不知道是什么原因。我仍然使用eclipse而不是android studio可以这也是一个原因吗?

解决方案

OK傻的答案,以前我在使用cordova 4.0和eclipse正在使用蚂蚁构建。



但是从cordova 5.0它需要毕业。我刚刚安装了android studio并映射了我的旧sdk与eclipse一起下载。当我映射它并打开一个cordova创建项目在android工作室。
我有一个错误,但是由于这里有一个stackoverflow问题 ,我解决了这个问题。



创建新项目,需要一些时间来下载所有依赖项,但最后解决了。现在我可以使用CMD创建。



所以答案的关键是你需要安装android studio,如果你还在使用eclipse。


I just updated cordova version from 4.0 to 5.1, and everything worked fine also in creating project. But as soon as I gave command of cordova build I got below error.

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

After 2 days suffering I came to know it's coming due to gradle, I downloaded and added it also in environment variable. I do get this error also when I go to android folder in cordova project and give command of gradle init. Don't know what can be reason of it. Am still using eclipse instead of android studio can it also be a reason ?

解决方案

OK silly answer, previously I was using cordova 4.0 and eclipse which was using ant for build.

But from cordova 5.0 it requires gradle. I just installed android studio and mapped my old sdk downloaded with eclipse. As I mapped it and opened one of cordova created project in android studio. I got one error but due to one of stackoverflow question here, I solved the issue.

Created new project and it took some time to download all the dependencies, but at last it solved. Now I can create with CMD.

So key of the answer is you need to install android studio if you are still using eclipse.

这篇关于在创建cordova项目时遇到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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