下载 Gradle 时 Ionic 构建 Android 错误 [英] Ionic build Android error when downloading Gradle
问题描述
我对 Ionic 框架很陌生:)
I'm very new to the Ionic framework :)
>npm install -g cordova
>npm install -g ionic
>ionic start test blank
>cd test
>ionic platform add android
当我使用 '>ionic build android
' 开始下载 gradle,但我无法下载并出现错误.
When I use '>ionic build android
' start download gradle, but I can't download and get an error.
是什么导致了这个错误,我该如何解决?!
What caused this error and how can I fix it?!
我下载了 Gradle 并将其安装在 PC 上,但它想再次下载.我可以离线将 Gradle 添加到项目中吗?
I download Gradle and install it on a PC, but it wants to download again. Can I add Gradle to a project offline?
C:UsersLENOVO2014 est>ionic build android
running cordova build android
Running command: "C:Program Files
odejs
ode.exe" C:UsersLENOVO2014myAppho
oksafter_prepare 10_add_platform_class.js C:UsersLENOVO2014myApp
add to body class: platform-android
Running command: C:UsersLENOVO2014myAppplatformsandroidcordovauild.bat
ANDROID_HOME=D:programProgramingAndroidsdk
JAVA_HOME=C:Program FilesJavajdk1.8.0_31
Running: C:UsersLENOVO2014myAppplatformsandroidgradlew cdvBuildDebug -b C:
UsersLENOVO2014myAppplatformsandroiduild.gradle -Dorg.gradle.daemon=true
Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
................................................................................
................................................................................
................................................................................
............................................
Exception in thread "main" java.lang.RuntimeException: java.net.SocketException:
Connection reset
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:78)
at org.gradle.wrapper.Install.createDist(Install.java:47)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:189)
at java.net.SocketInputStream.read(SocketInputStream.java:121)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.MeteredStream.read(MeteredStream.java:134)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Http
URLConnection.java:3335)
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Http
URLConnection.java:3328)
at org.gradle.wrapper.Download.downloadInternal(Download.java:63)
at org.gradle.wrapper.Download.download(Download.java:45)
at org.gradle.wrapper.Install$1.call(Install.java:60)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
... 3 more
C:UsersLENOVO2014myAppplatformsandroidcordova
ode_modulesqq.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:UsersLENOVO2014myAppplatfo
rmsandroidgradlew cdvBuildDebug -b C:UsersLENOVO2014myAppplatformsandroid
uild.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: C:UsersLENOVO2014myAppplatforms
androidcordovauild.bat: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: C:UsersLENOVO2014myAppplatformsandroidcordovauild.bat: Command fa
iled with exit code 1
at ChildProcess.whenDone (C:UsersLENOVO2014AppDataRoaming
pm
ode_modul
escordova
ode_modulescordova-libsrccordovasuperspawn.js:131:23)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1015:16)
at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
推荐答案
我使用的是 Ionic 版本 1.7.14 和以下文件中的 distributionUrl.myApp/platforms/android/cordova/lib/builders/GradleBuilder.js.
I am using Ionic version 1.7.14 and the distributionUrl found in the following file. myApp/platforms/android/cordova/lib/builders/GradleBuilder.js.
我必须指向本答案中指定的本地下载的 gradle.
I had to point the locally downloaded gradle as specified in this answer.
我遇到了同样的问题.我离线将 gradle 添加到我的项目中.
I had the same problem. I added gradle to my project offline.
从发布的链接下载 gradle 后(这里是 http://services.gradle.org/distributions/gradle-2.2.1-all.zip) 将其粘贴到诸如 myAppplatformsandroidgradlegradle-2.2.1-all.zip
之类的地方并在 myAppplatformsandroidcordovalibuild.js
中的 build.js 中找到:
After downloading gradle from issued link (here is http://services.gradle.org/distributions/gradle-2.2.1-all.zip) paste it in somewhere likes myAppplatformsandroidgradlegradle-2.2.1-all.zip
and in build.js from myAppplatformsandroidcordovalibuild.js
find this:
var distributionUrl = 'distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
并将其替换为您自己的文件位置:
And replace it with your own file's location:
var distributionUrl = 'distributionUrl=../gradle-2.2.1-all.zip';
这篇关于下载 Gradle 时 Ionic 构建 Android 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!