`ionic platform add android`失败了吗?

时间:2017-01-03 04:53:53

标签: cordova gradle ionic-framework

ionic platform add android出现以下错误。怎么解决?该文件应该从其他来源下载吗?

BUILD FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not download gradle.jar (com.android.tools.build:gradle:2.2.0)
      > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.jar'.
         > Failed to move file 'C:\Users\....\AppData\Local\Temp\gradle_download5163584130402676113bin' into filestore a
t 'C:\Users\....\.gradle\caches\modules-2\files-2.1\com.android.tools.build\gradle\2.2.0\e15d0f8c5ca4d152ec0ef5654b47d31
c899ea22e\gradle-2.2.0.jar'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Total time: 1 mins 31.633 secs

Failed to install 'cordova-plugin-console':Error: cmd: Command failed with exit code 1
    at ChildProcess.whenDone (D:\Users\....\myApp\platforms\android\cordova\node_modules\cordova-commo
n\src\superspawn.js:169:23)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

Error: cmd: Command failed with exit code 1

2 个答案:

答案 0 :(得分:0)

gradle.jar错误主要是因为cordova的安装不成功,或者在安装时会破坏​​某些地方

所以尝试通过以下命令卸载cordova并再次安装

npm uninstall -g cordova

确保Cordova版本6.4.0存在很多问题,因此请安装特定版本

npm install -g cordova@6.2.0 // 6.2.0 is still working fine

然后再次安装离子

npm install -g ionic

有关Cordova版本问题,请参阅我的回答here

另请告诉我这是否(gradle error solution)适合您。

答案 1 :(得分:0)

这是我发布的答案。请遵循以下准则以使其有效。 https://stackoverflow.com/a/41345071/6554634不要错过任何一步。不要忘记为所有环境变量提供正确的路径。确保您的SDK平台工具构建工具是最新的。如果不是,请更新SDK。