Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows cordova build error: Failed to find 'ANDROID_HOME' environment variable

OS: Windows 7.

I have created a project in cordova, but when I try to build it with the command cordova build android, it returns an error which says:

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)

I've already set up a variable named ANDROID_HOME in the user environment variables with the path to my android sdk: E:\android\sdk. Still i'm getting this error.

like image 870
Mr PyCharm Avatar asked Sep 26 '22 07:09

Mr PyCharm


2 Answers

Your path is not OK, you have to reference

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

Into the Path variable

For checking if this is correctly installed, just enter android in your console, and check if there are no errors

like image 154
Víctor Avatar answered Sep 28 '22 14:09

Víctor


Had the same issue, fixed it by renaming a folder called "Fastboot" in my C:/ drive's root.

like image 35
mz7xd Avatar answered Sep 28 '22 15:09

mz7xd