添加Android平台时出现以下错误。我检查了ant -version并正确输出了它。另外,我注意到在创建myApp文件夹node_modules时未与它一起获取。下面是我的控制台的输出:

Adding platform android
Creating android project...

C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\node_modules\q\q.js:126
                    throw e;
                          ^
Error: An error occurred while listing Android targets
    at C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\lib\check_reqs.js
:87:29
    at _rejected (C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\node_m
odules\q\q.js:808:24)
    at C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\node_modules\q\q.
js:834:30
    at Promise.when (C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\nod
e_modules\q\q.js:1079:31)
    at Promise.promise.promiseDispatch (C:\Users\Riliwan\.cordova\lib\android\co
rdova\3.5.0\bin\node_modules\q\q.js:752:41)
    at C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\node_modules\q\q.
js:574:44
    at flush (C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\node_modul
es\q\q.js:108:17)
    at process._tickCallback (node.js:419:13)
Error: C:\Users\user\.cordova\lib\android\cordova\3.5.0\bin\create.bat: Comma
nd failed with exit code 8
    at ChildProcess.whenDone (C:\Users\Riliwan\AppData\Roaming\npm\node_modules\
cordova\node_modules\cordova-lib\src\cordova\superspawn.js:131:23)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:753:16)
    at Process.ChildProcess._handle.onexit (child_process.js:820:5)
Unable to add platform android. Please see console for more info.

最佳答案

我正在使用Ubuntu 14.04并通过将这些路径设置为O.S来修复它。路径:

export ANDROID_HOME=/home/coutinho/android-sdk
export ANDROID_TOOLS=/home/coutinho/android-sdk/tools/
export ANDROID_PLATFORM_TOOLS=/home/coutinho/android-sdk/platform-tools/

PATH=$PATH:$ANDROID_HOME:$ANDROID_TOOLS:$ANDROID_PLATFORM_TOOLS:.


然后工作正常。

关于cordova - 在Windows的Ionic Framework中添加平台时出错,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23960763/

10-10 17:13