Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while building android platform at cmd

Error at cmd when building ionic project with android

[Error: 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.]
    ERROR building one of the platforms: Error: cmd: Command failed with exit code 2
    You may not have the required environment or OS to build this project
    Error: cmd: Command failed with exit code 2
     at ChildProcess.whenDone (C:\Users\Hasan\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:139:23)
     at ChildProcess.emit (events.js:110:17)
     at maybeClose (child_process.js:1015:16)
     at Process.ChildProcess.handle.onexit (childprocess.js:1087:5)

so what is the problem what must I do to fix it ?? I have android sdk on my pc, and m working on windows 10, I have installed nodejs. Can anybody help me

like image 656
hasan shmsdn Avatar asked Mar 25 '26 06:03

hasan shmsdn


2 Answers

Go to Advanced System Settings, then go to Environment Variables and select PATH variable to edit. There you have to append path to platform tools and tools of sdk, for example like this
;C:\Development\android-sdk\platform-tools;C:\Development\android-sdk\tools

Now go to cmd and run android, if that does not open android sdk manager, then it means path has not been set correctly or cmd is not recognizing enviroment variable updtes, in that case restart your computer and it will work.

like image 64
Mudasser Ajaz Avatar answered Mar 26 '26 23:03

Mudasser Ajaz


Go to Advanced System Settings, then go to Environment Variables Then add new Variables with name "ANDROID_HOME" and the value will be you SDK path like

C:\Android\sdk

Make sure to restart visual studio before run again

it will fix

like image 27
Hussein Alrubaye Avatar answered Mar 27 '26 00:03

Hussein Alrubaye



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!