我正在使用Windows 7X64计算机并尝试使用cordova/ionic CLI v1.5.5
构建Andriod应用程序。我收到了这个我无法解决的错误。
"You may not have the required environment or OS to build this project"
使用命令ionic build android
和cordova build android
。命令ionic platform add android
成功。我正在使用Android SDK Manager使用Android sdk(API 22)。我还确保正确设置了PATH变量。
流程的完整记录是:
C:\Users\ddevkota\Desktop\freshIonic>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\ddevkota\Desktop\fr
eshIonic\hooks\after_prepare\010_add_platform_class.js C:\Users\ddevkota\Desktop
\freshIonic
add to body class: platform-android
Running command: cmd "/s /c "C:\Users\ddevkota\Desktop\freshIonic\platforms\andr
oid\cordova\build.bat""
ANDROID_HOME=C:\Users\ddevkota\AppData\Local\Android\sdk
JAVA_HOME=C:\Progra~1\Java\jdk1.7.0_15
Running: C:\Users\ddevkota\Desktop\freshIonic\platforms\android\gradlew cdvBuild
Debug -b C:\Users\ddevkota\Desktop\freshIonic\platforms\android\build.gradle -Do
rg.gradle.daemon=true
Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
Exception in thread "main" java.lang.RuntimeException: java.io.IOException: Serv
er returned HTTP response code: 403 for URL: http://services.gradle.org/distribu
tions/gradle-2.2.1-all.zip
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.io.IOException: Server returned HTTP response code: 403 for URL:
http://services.gradle.org/distributions/gradle-2.2.1-all.zip
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1625)
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
C:\Users\ddevkota\Desktop\freshIonic\platforms\android\cordova\node_modules\q\q.
js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\ddevkota\Desktop\freshI
onic\platforms\android\gradlew cdvBuildDebug -b C:\Users\ddevkota\Desktop\freshI
onic\platforms\android\build.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone (C:\Users\ddevkota\AppData\Roaming\npm\node_modules
\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:134: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)
提前感谢您的帮助。
答案 0 :(得分:3)
注意:这是一个网络问题。 403是网络问题。我将我的机器连接到不同的网络,它开始工作。所有构建过程。如果你想手动完成这里我有多远。
解决方案无效JAVA_HOME
花了几天时间并卸载所有版本的java,只重新安装一个版本并将环境变量JAVA_HOME
设置为C:\Program Files\Java\jdk1.7.0_15
我解决了这个问题。
然而,下载gradle时还存在另一个离子构建android错误的问题。
当我在离线时将gradle添加到我的项目中时,这已经解决了。
不是Gradle 403 Http响应的解决方案
执行以下操作:
从已发布的链接(此处为http://services.gradle.org/distributions/gradle-2.2.1-all.zip)下载gradle后,将其粘贴到myApp\platforms\android\gradle\gradle-2.2.1-all.zip
之类的某个地方以及myApp\platforms\android\cordova\lib\build.js
的build.js中找到:
var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip'
;
并将其替换为您自己的文件位置:
var distributionUrl = 'distributionUrl=../gradle-2.2.1-all.zip';
仍然致力于构建并将继续发布解决方案。在离子论坛中创建了一个关于其他问题的主题,它是here。
答案 1 :(得分:1)
Gradle 403 Http 响应不响应的解决方案
在以下位置找到 distributionUrl 变量:
myapp\platforms\android\cordova\lib\builders\GradleBuilder.js
在此行中将 http
值更改为 https
:
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip';