如何在ionic,cordova和android中创建项目?

时间:2014-09-25 07:31:40

标签: android cordova ionic-framework

我已安装了ionic,cordova和android。 但离子不是创造android项目。 我附上了错误。

C:\Users\shri\myapp>ionic platform add android Creating android project... C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:126 throw e; ^ Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions. at C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\lib\check_reqs.js:158:19 at _fulfilled (C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:798:54) at self.promiseDispatch.done (C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:827:30) at Promise.promise.promiseDispatch (C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:760:13) at C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:821:14 at flush (C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\node_modules\q\q.js:108:17) at process._tickCallback (node.js:419:13) at Function.Module.runMain (module.js:499:11) at startup (node.js:119:16) at node.js:906:3 Error: C:\Users\shri.cordova\lib\npm_cache\cordova-android\3.6.3\package\bin\create.bat: Command failed with exit code 8 at ChildProcess.whenDone (C:\Users\shri\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23) at ChildProcess.emit (events.js:98:17) at maybeClose (child_process.js:756:16) at Process.ChildProcess._handle.onexit (child_process.js:823:5)

1 个答案:

答案 0 :(得分:0)

您需要在PATH中包含ANDROID_HOME。我建议您执行以下操作(假设您使用的是Windows 8.1):

右键单击任务栏中的图块启动器图标,然后选择系统。在弹出的窗口中,选择左侧的高级系统设置。在系统属性窗口中,单击环境变量按钮,然后选择添加新的系统变量。对于名称,请选择ANDROID_HOME,并且值包括Android SDK目录的完整路径。

编辑PATH变量并将以下内容添加到值的末尾:

<强>;%ANDROID_HOME%\工具;%ANDROID_HOME%\平台工具

重新启动Windows会话,它现在应该可以正常工作。