Ionic 构建 Android 失败
2015-10-31
2159
我真的不知道该如何为 Android 构建 Ionic
系统信息
Cordova CLI: 5.3.3
Ionic Version: 1.1.0
Ionic CLI Version: 1.7.7
Ionic App Lib Version: 0.6.3
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Mac OS X El Capitan
Node Version: v0.12.6
Xcode version: Xcode 7.0.1 Build version 7A1001
当我运行
$ ionic build android
它会产生
Running command: /Users/umer/Workspace/Ionic/blank/hooks/after_prepare/010_add_platform_class.js /Users/umer/Workspace/Ionic/blank
add to body class: platform-android
Running command: /Users/umer/Workspace/Ionic/blank/hooks/after_prepare/020_remove_sass_from_platforms.js /Users/umer/Workspace/Ionic/blank
Running command: /Users/umer/Workspace/Ionic/blank/platforms/android/cordova/build
ANDROID_HOME=/Users/umer/Documents/android-sdk-macosx
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_31.jdk/Contents/Home
Running: /Users/umer/Workspace/Ionic/blank/platforms/android/gradlew cdvBuildDebug -b /Users/umer/Workspace/Ionic/blank/platforms/android/build.gradle -Dorg.gradle.daemon=true
Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: /var/root/.gradle/wrapper/dists/gradle-2.2.1-all/2m8005s69iu8v0oiejfej094b/gradle-2.2.1-all.zip
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:61)
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)
/Users/umer/Workspace/Ionic/blank/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: /Users/umer/Workspace/Ionic/blank/platforms/android/gradlew with args: cdvBuildDebug,-b,/Users/umer/Workspace/Ionic/blank/platforms/android/build.gradle,-Dorg.gradle.daemon=true
ERROR building one of the platforms: Error: /Users/umer/Workspace/Ionic/blank/platforms/android/cordova/build: Command failed with exit code 1
You may not have the required environment or OS to build this project
Error: /Users/umer/Workspace/Ionic/blank/platforms/android/cordova/build: Command failed with exit code 1
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/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)
我尝试更改
var distributionUrl = 'distributionUrl=http\\://services.gradle.org/distributions/gradle-2.2.1-all.zip';
以将其指向本地分发,但它不会查看指定的路径,而是查看项目的 android 目录。
当我使用 Ant 构建时
cordova build android -- --ant
它构建成功,但我无法按照文档建议的方式进行构建。
我已经关注了 下载 gradle 时出现 ionic build android 错误
1个回答
我在多次运行 android 命令时收到此错误。我运行了(在 Linux 上):
ps aux | grep -i android
我发现 android 命令运行了不止一次。
我输入了
sudo kill -9 (ids of running android(s) )
看来 android 拒绝了 ionic 访问 gradle。
Roddy P. Carbonell
2016-02-13