Phonegap: Command failed with exit code 8

2019-07-21 16:34发布

问题:

I'm setting up an environment for Phonegap developing, and I'm getting some trouble to finally build and run an app for Android.

When I try to execute build for Android, I got the following error:

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)

Some details:

  • I'm running on Windows 8.1;
  • I'm using Android SDK 22;
  • I've already created environment variables for JDK, Android (tools, build-tools and platform-tools), Ant and Gradle.

Any ideas why am I getting this error?

Thank you.

回答1:

I have already managed to solve this problem, so, in case of anyone has a similar trouble, here it goes the situation I've gone through.

When I performed the first build, phonegap attempted to download and extract it's own gradle distribution, and he was attempting to download it from the follow:

http://services.gradle.org/distributions/gradle-2.2.1-all.zip

By the time, I was connected on university's network, and this URL was blocked by it's proxy. Since I wasn't able to reach the URL above, all Phonegap could do was to get a corrupted zip file, so that was the reason that exception has been throwed.

Even when I deleted ~/.gradle, I was trying to build on the same network.

So, in order to solve this problem, I have just deleted .gradle directory and run the build using another network connection.