ionic build android error

2020-02-06 16:31发布

I'm confused. jdk,sdk,ant,cordova,ionic doing well,why builds error?
I searched everywhere,but no answer for it.
I guess has a error version?
who can help this?

system:win8
jdk:1.8
ant:1.96
android:22

%ANT_HOME%\bin\;%ANDROID_HOME%\platform-tools\;%ANDROID_HOME%\tools\;%java_home%\bin;%java_home%\jre\bin;C:\ProgramData\Oracle\Java\javapath;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\

Path

E:\ionic\demo22>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" E:\ionic\demo22\hooks\after_
prepare\010_add_platform_class.js E:\ionic\demo22
add to body class: platform-android
Running command: cmd "/s /c "E:\ionic\demo22\platforms\android\cordova\build.bat
""
ANDROID_HOME=E:\adt-bundle-windows-x86_64-20140702\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
Running: E:\ionic\demo22\platforms\android\gradlew cdvBuildDebug -b E:\ionic\dem
o22\platforms\android\build.gradle -Dorg.gradle.daemon=true
Unzipping C:\Users\cxt\.gradle\wrapper\dists\gradle-2.2.1-all\2m8005s69iu8v0oiej
fej094b\gradle-2.2.1-all.zip to C:\Users\cxt\.gradle\wrapper\dists\gradle-2.2.1-
all\2m8005s69iu8v0oiejfej094b
Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipExceptio
n: error in opening zip file
        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:219)
        at java.util.zip.ZipFile.<init>(ZipFile.java:149)
        at java.util.zip.ZipFile.<init>(ZipFile.java:163)
        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

E:\ionic\demo22\platforms\android\cordova\node_modules\q\q.js:126
                    throw e;
                          ^
Error code 1 for command: cmd with args: /s /c "E:\ionic\demo22\platforms\androi
d\gradlew cdvBuildDebug -b E:\ionic\demo22\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\cxt\AppData\Roaming\npm\node_modules\cord
ova\node_modules\cordova-lib\src\cordova\superspawn.js:139: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)

Error

3条回答
ゆ 、 Hurt°
2楼-- · 2020-02-06 17:16

I hope that not too late, but I had the same error and. So, I fixed it doing the next:

In your case find this:

C:\Users\cxt.gradle\wrapper\dists\gradle-2.2.1- all\2m8005s69iu8v0oiejfej094b

now when you are here delete the gradle-2.2.1-all.zip because this file is corrupted and then we'll replace for this http://services.gradle.org/distributions/gradle-2.2.1-all.zip when you finish all try again

ionic build android

Good Luck!

查看更多
贪生不怕死
3楼-- · 2020-02-06 17:29

First of all you have to install

  1. node.js
  2. apache ANT
  3. JDK & JRE
  4. Android SDK & Eclipse

After installation, you have to set software paths into environmental- variable. Then fire your npm install -g cordova. Without this PhoneGap will not be created.

If still you have any confusion or question related to software installation then tell me.

查看更多
爷的心禁止访问
4楼-- · 2020-02-06 17:36

I had the same issue on Mac. The steps below solved that for me:

NOTE: gradle path & version would be different on your machine. please replace those informations with yours. you can get them from exception message

sudo ls rm /var/root/.gradle/wrapper/dists/gradle-2.13-all/7hsc6vr6mi3i6i5m7q9hj4ci1q

  • Remove existing zip file

sudo rm /var/root/.gradle/wrapper/dists/gradle-2.13-all/7hsc6vr6mi3i6i5m7q9hj4ci1q/gradle-2.13-all.zip

  • If there is a *.zip.lck file, you'd better remove that too..

sudo rm /var/root/.gradle/wrapper/dists/gradle-2.13-all/7hsc6vr6mi3i6i5m7q9hj4ci1q/gradle-2.13-all.zip.lck

  • Copy downloaded file to that path

sudo cp /Downloads/gradle-2.13-all.zip /var/root/.gradle/wrapper/dists/gradle-2.13-all/7hsc6vr6mi3i6i5m7q9hj4ci1q/

Then try to run

ionic run android

查看更多
登录 后发表回答