我最近将我的Cordova更新到5.1.1以及JDK到1.7.0.79。我还创建了一个新的Cordova android项目。但是当我尝试使用CLI构建项目时,它会给我以下错误:
Your environment has been set up for using Node.js 0.10.28 (ia32) and npm.
C:\Documents and Settings\Administrator>F:
F:\>cd shishutosh
F:\shishutosh>cordova build android
Running command: cmd "/s /c "F:\shishutosh\platforms\android\cordova\build.bat""
ANDROID_HOME=E:\Backup\Software\adt-bundle-windows-x86-20130729\adt-bundle-windo
ws-x86-20130729\sdk\
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
Running: F:\shishutosh\platforms\android\gradlew cdvBuildDebug -b F:\shishutosh\
platforms\android\build.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.UnknownHostExcep
tion: services.gradle.org
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.UnknownHostException: services.gradle.org
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java
:178)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLC
onnection.java:997)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConne
ction.java:933)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection
.java:851)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1301)
at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
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
F:\shishutosh\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "F:\shishutosh\platforms\android\
gradlew cdvBuildDebug -b F:\shishutosh\platforms\android\build.gradle -Dorg.grad
le.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 8
at ChildProcess.whenDone (C:\Documents and Settings\Administrator\Applicatio
n Data\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.
js:134:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
F:\shishutosh>
我手动安装了Grandle并设置了环境变量。并验证如下:
F:\Rong>gradle -v
------------------------------------------------------------
Gradle 2.2.1
------------------------------------------------------------
Build time: 2014-11-24 09:45:35 UTC
Build number: none
Revision: 6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
Groovy: 2.3.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.7.0_79 (Oracle Corporation 24.79-b02)
OS: Windows 2003 5.2 x86
我以前创建的项目运行CLI&#34; BUILD COMMAND&#34;没有任何错误。任何人都可以就此问题给我一些解决方案。
提前致谢。
N.B。我是公司代理人的背后。
答案 0 :(得分:4)
我有同样的问题。我无法弄清楚,但如果您安装了ANT并配置了路径,则有一种解决方法。 尝试命令&#34; cordova build android - -ant&#34; (仍在寻找正确的解决方案)
答案 1 :(得分:0)
这是因为gradle错误下载文件
<强> http://services.gradle.org/distributions/gradle-2.14.1-all.zip 强>
并在任何目录中解压缩并通过open cmd和设置路径 输入
setx路径(提取的direstory)/ bin
检查gradle是否有效 给
gradle -v
显示gradle版本输出。
现在错误已修复运行 ionic build android