创建cordova项目时出现gradle错误 [英] getting gradle error while creating cordova project

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

问题描述

我刚刚将cordova 版本从4.0 更新到5.1,并且在创建项目时一切正常.但是,一旦我发出 cordova build 命令,我就会收到以下错误.

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

经过 2 天的痛苦,我知道它会因为 gradle 而出现,我下载并将它添加到环境变量中.当我转到cordova项目中的android文件夹并发出gradle init命令时,我也会收到此错误.不知道是什么原因.我还在使用 eclipse 而不是 android studio 这也是一个原因吗?

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 ?

推荐答案

好吧,愚蠢的回答,之前我使用的是cordova 4.0 和使用ant 进行构建的eclipse.

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

但是从cordova 5.0开始它需要gradle.我刚刚安装了android studio并映射了我用eclipse下载的旧sdk.当我映射它并在android studio中打开cordova创建的项目之一时.我遇到了一个错误,但由于 这里有一个 stackoverflow 问题,我解决了问题.

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.

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

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

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

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

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