我为Phonegap开发设置了一个环境,我最终为Android构建和运行应用程序遇到了一些麻烦。
当我尝试执行Android版构建时,出现以下错误:
Running: C:\Users\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platfor
ms\android\gradlew cdvBuildDebug -b C:\Users\Renan\workspace_html5\FIAP\Phonegap
\phonegap-test\test\platforms\android\build.gradle -Dorg.gradle.daemon=true
Unzipping C:\Users\Renan\.gradle\wrapper\dists\gradle-2.2.1-all\2m8005s69iu8v0oi
ejfej094b\gradle-2.2.1-all.zip to C:\Users\Renan\.gradle\wrapper\dists\gradle-2.
2.1-all\2m8005s69iu8v0oiejfej094b
Exception in thread "main"
java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip fil
e
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.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:220)
at java.util.zip.ZipFile.<init>(ZipFile.java:150)
at java.util.zip.ZipFile.<init>(ZipFile.java:164)
at org.gradle.wrapper.Install.unzip(Install.java:160)
at org.gradle.wrapper.Install.access$400(Install.java:29)
at org.gradle.wrapper.Install$1.call(Install.java:70)
at org.gradle.wrapper.Install$1.call(Install.java:47)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
... 3 more
C:\Users\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platforms\androi
d\cordova\node_modules\q\q.js:126
throw e;
^
Error code 1 for command: cmd with args: /s /c "C:\Users\Renan\workspace_html5\F
IAP\Phonegap\phonegap-test\test\platforms\android\gradlew cdvBuildDebug -b C:\Us
ers\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platforms\android\bui
ld.gradle -Dorg.gradle.daemon=true"
ERROR building one of the platforms: Error: C:\Users\Renan\workspace_html5\FIAP\
Phonegap\phonegap-test\test\platforms\android\cordova\build.bat: Command failed
with exit code 8
You may not have the required environment or OS to build this project
Error: C:\Users\Renan\workspace_html5\FIAP\Phonegap\phonegap-test\test\platforms
\android\cordova\build.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\Renan\AppData\Roaming\npm\node_modules\ph
onegap\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:1
31:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)
一些细节:
任何想法我为什么会收到此错误?
谢谢。
答案 0 :(得分:3)
我已经设法解决了这个问题,所以,如果有人遇到类似的麻烦,这就是我经历过的情况。
当我执行第一次构建时,phonegap尝试下载并提取它自己的gradle分发,并且他试图从以下内容下载它:
http://services.gradle.org/distributions/gradle-2.2.1-all.zip
当时,我在大学网络上已关联,此网址被其代理人阻止。由于我无法访问上述网址,因此所有Phonegap都可以获得损坏的zip文件,因此这就是抛出异常的原因。
即使我删除〜/ .gradle,我也试图在同一个网络上构建。
因此,为了解决这个问题,我刚刚删除了.gradle目录并使用另一个网络连接运行构建。