cordova - 第三节-常见错误
常见错误
gradle 没有正确下载
- 运行命令 cordova platform add android –save 提示错误
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
hansdeMacBook-Pro:Jd-mobile-app hans$ cordova platform add android --save
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.itcast.jd.mobile
Name: JdMobileApp
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android@6.0.0
Installing "cordova-plugin-inappbrowser" for android
ANDROID_HOME=/Users/hans/Documents/Eclipse/sdk/
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
Subproject Path: CordovaLib
Unzipping /Users/hans/.gradle/wrapper/dists/gradle-2.14.1-all/53l0mv9mggp9q5m2ip574m21oh/gradle-2.14.1-all.zip to /Users/hans/.gradle/wrapper/dists/gradle-2.14.1-all/53l0mv9mggp9q5m2ip574m21oh
Exception in thread "main" java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.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(ExclusiveFileAccessManager.java:65)
... 3 more
Failed to install 'cordova-plugin-inappbrowser':Error: /Users/hans/Documents/itcast-project/电商网站/Jd-mobile-app/platforms/android/gradlew: Command failed with exit code 1
at ChildProcess.whenDone (/Users/hans/Documents/itcast-project/电商网站/Jd-mobile-app/platforms/android/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:821:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Error: /Users/hans/Documents/itcast-project/电商网站/Jd-mobile-app/platforms/android/gradlew: Command failed with exit code 1
错误信息很多,这是java堆栈方式抛出错误,我从顶部开始看 Unzipping /Users/hans/.gradle/wrapper/dists/gradle-2.14.1-all/53l0mv9mggp9q5m2ip574m21oh/gradle-2.14.1-all.zip to /Users/hans/.gradle/wrapper/dists/gradle-2.14.1-all/53l0mv9mggp9q5m2ip574m21oh Exception in thread “main” java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file 有这两行描述,我们打开文件夹浏览 /Users/hans/.gradle/wrapper/dists/gradle-2.14.1-all/53l0mv9mggp9q5m2ip574m21oh/gradle-2.14.1-all.zip
- 方法一: 删除 gradle-2.14.1-all.zip 下载失败的文件
去官网下载正确的 https://services.gradle.org/distributions
- 方法二: 删除 gradle-2.14.1-all.zip , 删除 /platforms/android/ 文件夹 ,重新运行 命令 cordova platform add android –save
会自动重新下载gradle-2.14.1-all.zip,并执行后续操作
#