Windows cordova构建错误:无法找到'ANDROID_HOME'环境变量

时间:2016-02-21 09:51:30

标签: android cordova

操作系统:Windows 7。

我在cordova中创建了一个项目,但是当我尝试使用命令cordova build android构建它时,它会返回一个错误,其中包含:

ERROR building one of the platforms: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
You may not have the required environment or OS to build this project
Error: CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
at C:\Users\Ahmed\Desktop\nodejs\hello\platforms\android\cordova\lib\check_reqs.js:223:19
at _fulfilled (C:\Users\Ahmed\Desktop\nodejs\hello\platforms\android\cordova\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\Ahmed\Desktop\nodejs\hello\platforms\android\cordova\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\Ahmed\Desktop\nodejs\hello\platforms\android\cordova\node_modules\q\q.js:796:13)
at C:\Users\Ahmed\Desktop\nodejs\hello\platforms\android\cordova\node_modules\q\q.js:857:14
at runSingle (C:\Users\Ahmed\Desktop\nodejs\hello\platforms\android\cordova\node_modules\q\q.js:137:13)
at flush (C:\Users\Ahmed\Desktop\nodejs\hello\platforms\android\cordova\node_modules\q\q.js:125:13)
at nextTickCallbackWith0Args (node.js:453:9)
at process._tickCallback (node.js:382:13)
at Function.Module.runMain (module.js:449:11)

我已经在用户环境变量中设置了一个名为ANDROID_HOME的变量,其路径为我的android sdk:E:\android\sdk。我仍然收到这个错误。

2 个答案:

答案 0 :(得分:4)

你的路径不行,你必须参考

E:\android\sdk\tools
E:\android\sdk\platform-tools

进入Path变量

要检查是否已正确安装,只需在控制台中输入android,然后检查是否没有错误

答案 1 :(得分:0)

遇到相同的问题,通过在我的C:/驱动器根目录中重命名一个名为“ Fastboot”的文件夹来解决此问题。