2014-09-11 76 views
0

我正在使用Mac上的cordova 3.5項目。我已經使用CLI創建和構建。但Android構建失敗。我設置了sdk路徑。以下是我收到的錯誤。我沒有添加任何插件。Phonegap(cordova 3.5)Android Build失敗

cordova build android 

Generating config.xml from defaults for platform "android" 
Preparing android project 
Compiling app on platform "android" via command "/Users/user/Documents/Phonegap_Projects/Test1/platforms/android/cordova/build" 
Error: An error occurred while building the android project.Error executing "ant debug -f "/Users/user/Documents/Phonegap_Projects/Test1/platforms/android/build.xml"": 
BUILD FAILED 
/Users/user/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:601: The following error occurred while executing this line: 
/Users/user/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:720: The following error occurred while executing this line: 
/Users/user/Documents/adt-bundle-mac-x86_64-20140702/sdk/tools/ant/build.xml:734: Class not found: javac1.8 

Total time: 2 seconds 


at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22) 
at ChildProcess.emit (events.js:98:17) 
at maybeClose (child_process.js:756:16) 
at Socket.<anonymous> (child_process.js:969:11) 
at Socket.emit (events.js:95:17) 
at Pipe.close (net.js:465:12) 

回答

1

看起來像java編譯器不在你的PATH。看看PhoneGap Android Platform Guide

您可能還需要啓用Java和Ant。打開命令提示符並鍵入java,並鍵入ant。附加到這些爲準的 無法運行的路徑:

;%JAVA_HOME%\bin;%ANT_HOME%\bin 

您可以通過在命令提示符下運行javac測試您的配置。

+0

感謝您的回答。我認爲你回答適合windows系統。我正在使用Mac – 2014-09-12 12:06:51

+0

同樣的步驟適用於unix/linux。在windows上,通過對話框編輯%PATH%。在mac上,編輯〜/ .bash_profile,添加一行PATH = $ PATH:$ JAVA_HOME \ bin:$ PATH:$ ANT_HOME \ bin http://www.cyberciti.biz/faq/linux-unix-set- java_home-path-variable/ – kindasimple 2014-09-12 16:46:46

+1

當然,應該已經定義了JAVA_HOME變量。 – kindasimple 2014-09-12 16:47:55

相關問題