2015-05-05 53 views
0
Updated the hooks directory to have execute permissions 
running cordova build android 
Running command: "C:\Program Files\nodejs\node.exe" F:\ionic\myApp\hooks\after_prepare\010_add_platform_class.js F:\ionic\myApp 
add to body class: platform-android 
Running command: F:\ionic\myApp\platforms\android\cordova\build.bat 
ERROR building one of the platforms: Error: F:\ionic\myApp\platforms\android\cordova\build.bat: Command failed with exit code 2 
You may not have the required environment or OS to build this project 
Error: F:\ionic\myApp\platforms\android\cordova\build.bat: Command failed with exit code 2 
    at ChildProcess.whenDone (C:\Users\svkaushik17\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23) 
    at ChildProcess.emit (events.js:98:17) 
    at maybeClose (child_process.js:766:16) 
    at Process.ChildProcess._handle.onexit (child_process.js:833:5) 

請讓我知道是否有任何依賴關係需要安裝以構建應用程序。無法構建離子應用程序,出現錯誤:命令失敗,退出代碼爲2

我有Ionic網站來構建應用程序。

$ ionic platform add android 
$ ionic build android 

我也安裝了AVD管理器。

回答

0

在安裝過程中,您錯過了這部分依賴關係(Windows上的Java Ant爲Android)。

它可以在這裏找到:http://ionicframework.com/docs/guide/installation.html

Windows users developing for Android: You'll want to make sure you have the following installed and set up.

NOTE: Whenever you make changes to the PATH, or any other environment variable, you'll need to restart or open a new tab in your shell program for the PATH change to take effect.

Java JDK

Install the most recent Java JDK (NOT just the JRE).

Next, create an environment variable for JAVA_HOME pointing to the root folder where the Java JDK was installed. So, if you installed the JDK into C:\Program Files\Java\jdk7, set JAVA_HOME to be this path. After that, add the JDK's bin directory to the PATH variable as well. Following the previous assumption, this should be either %JAVA_HOME%\bin or the full path C:\Program Files\Java\jdk7\bin

Apache Ant

To install Ant, download a zip from here, extract it, move the first folder in the zip to a safe place, and update your PATH to include the bin folder in that folder. For example, if you moved the Ant folder to c:/, you'd want to add this to your PATH: C:\apache-ant-1.9.2\bin.

Android SDK

Installing the Android SDK is also necessary. The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android.

Cordova requires the ANDROID_HOME environment variable to be set. This should point to the [ANDROID_SDK_DIR]\android-sdk directory (for example c:\android\android-sdk).

Next, update your PATH to include the tools/ and platform-tools/ folder in that folder. So, using ANDROID_HOME, you would add both %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools.

0

確保沒有安裝2個版本的JDK。如果您安裝了2個版本,請嘗試將您的JAVA_HOME指向似乎可以解決問題的C:\ Program Files \版本。此外,cordova正在檢查javac不僅僅是java -version,所以從命令行嘗試javac並檢查它是否可用。

相關問題