2

I want to build an ionic app but when I run ionic build android on terminal it gives below error,

Running command: /home/shamil/learn/Ionic/myApp/hooks/after_prepare/010_add_platform_class.js /home/shamil/learn/Ionic/myApp
add to body class: platform-android
Running command: /home/shamil/learn/Ionic/myApp/platforms/android/cordova/build 
[Error: 'ANDROID_HOME' environment variable is set to non-existent path: /Android/Sdk
Try update it manually to point to valid SDK directory.]
ERROR building one of the platforms: Error: /home/shamil/learn/Ionic/myApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/shamil/learn/Ionic/myApp/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/local/lib/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 (child_process.js:1087:5)

I have given the correct path where sdk exist, but why there such an error exist? I have searched enough to solve this matter, but it still gives the same error.

Please help.

lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
shamila
  • 1,280
  • 6
  • 20
  • 45
  • 1
    see this link how to install Ionic framework on Ubuntu https://blog.nraboy.com/2014/09/install-android-cordova-ionic-framework-ubuntu/ – Anil kumar Sep 03 '15 at 05:29

3 Answers3

1

The error is self explaining:

[Error: 'ANDROID_HOME' environment variable is set to non-existent path: /Android/Sdk

This means that the /Android/Sdk path doesn't exists, so you should fix your $ANDROID_HOME environment variable to point to a real path.

To check that this path doesn't exists, run from the terminal: ls /Android/Sdk. You should receive a same error.

See this question to know how to set, permanently, this variable.

Community
  • 1
  • 1
lifeisfoo
  • 15,478
  • 6
  • 74
  • 115
  • 1
    I get the same error and my path is correct. In fact I copied it from explorer. On Windows this is what I have it set to -> "C:\Program Files (x86)\Android\android-sdk". And I still get the same error. – Sudeep Unnikrishnan Nov 01 '15 at 07:34
  • 5
    @Sudeep Unnikrishnan - I had the same issue in widows. What I did wrong is to set path with double quotes, e.g. set ANDROID_HOME="C:\Program Files (x86)\Android\android-sdk" ... instead I had to do without double quotes and it worked: set ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk – user1697575 Dec 28 '15 at 16:36
  • I get `non-existent path: /mnt/c/Android/LinuxSDK` and when I run `ls /mnt/c/Android/LinuxSDK` I get `build-tools licenses platforms platform-tools tools` – gattsbr Jan 04 '18 at 20:53
1

try changing from the My Computer->property->Advance System property->change Environment Variables.

I think this might work

Eshan Chattaraj
  • 368
  • 1
  • 6
  • 19
0

I added the environment variable to my system variables, closed the ms window and opened new one , issue was gone

Sameh
  • 1,318
  • 11
  • 11