14

When i run for android, i see this error :

ERROR: Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.

But this "variable" are ok. "Android" launch SDK manager and ANDROID_HOME redirect to my sdk folder.

I don't understand this error.

FYI my export :

export ANDROID_HOME=`brew --prefix android`
export PATH=${PATH}:$ANDROID_HOME/bin
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Sorcim
  • 251
  • 1
  • 2
  • 12
  • This answer worked for me. http://stackoverflow.com/questions/23960763/error-on-adding-platform-in-ionic-framework-on-windows – gfunk Sep 25 '14 at 21:26
  • The same error with your solution. – Sorcim Sep 26 '14 at 09:52
  • Which user "run for android" ? If your exports are in your personnal bashrc and if cordova is ran by another user, ANDROID_HOME could not be defined for him. – Paul Andrieux Sep 30 '14 at 22:27
  • For windows users who encounter with this error take a look at your environment variables set the right path for android sdk which defined as ANDROID_HOME – Serhat Koroglu Jun 12 '15 at 09:06

7 Answers7

11

I answer me !

My solution :

sudo chown -R your-user /usr/local/lib/node_modules/cordova

Remove and add platform

Sorcim
  • 251
  • 1
  • 2
  • 12
3

Ubuntu 14.04 gedit /root/.bashrc add line

export JAVA_HOME=/usr/lib/jvm/java-8-oracle/
ANDROID_HOME=/root/android/sdk/
export ANDROID_HOME=$ANDROID_HOME

PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/build-tools

IN TERMINAL source ~/.bashrc

Resolveu pra mim/Solved for me!

gilcierweb
  • 31
  • 2
1

When my environment is OK (which means that running 'android' via CLI will open the android sdk manager), but I still get this error...

I do the follow:

1 - Remove the platform Android from your project cordova platform remove android 2 - Then I just run again phonegap run android (it'll add the platform Android automatically)

Helder Robalo
  • 1,827
  • 2
  • 13
  • 16
1

Took me longer than I care to admit to solve this problem, so I thought I'd share how I got this working on Mac for the more novice users such as myself and also those who have not installed with Homebrew:

1) Open your bash profile file (the path to finding this file is 'User/.bash_profile', the name of your file may be .profile or something similar).

2) Add a path to wherever you have saved the Android SDK (you may add something like this: 'export PATH=${PATH}:/Applications/adt-bundle/sdk/platform-tools:/Applications/adt-bundle/sdk/tools' or you may add something like this: 'export PATH=${PATH}:/Desktop/adt-bundle/sdk/platform-tools:/Desktop/adt-bundle/sdk/tools').

Make sure the file name 'adt-bundle' shown in the path above is the name you have saved for the folder! If it isn't, either save the folder with this name, or alter the path to reflect what you have saved the folder as.

3) Try again. You might encounter some further errors, I resolved mine by visiting this page: Cordova 3.5.0 Install Error- Please Install Android Target 19 I typed 'Android' in the terminal to head straight to the package manager in Eclipse. After installing the required version the command worked and installed the Android package to my Cordova application.

I found the following pages very helpful in coming to the above conclusions:

-Understanding the path (needed a refresher on using path! Last time I had to bother with this was ages ago when installing the rbenv Ruby environment): http://help.exercism.io/understanding-path.html

-Setting up for Android (where I found the path): http://docs.phonegap.com/en/edge/guide_platforms_android_index.md.html#Using%20Plugman%20to%20Manage%0APlugins

No 'sudo' required.

Community
  • 1
  • 1
0

I had to close and re-open my windows console (or open a new console), and then open the SDK manager (ran android), after which a bunch of updates and installs had to complete.

maudulus
  • 10,627
  • 10
  • 78
  • 117
0

For me following steps work :

sudo chown -R your-user /usr/local/lib/node_modules/cordova

export PATH=$PATH:/users/your-user/android-sdks/tools

and then update your android if it is not updated to latest version.

http://blog.codersight.com/2015/05/error-androidhome-is-not-set-and.html

Naushad Qamar
  • 123
  • 3
  • 14
0

For anybody like me who has tried everything in the answers and have all the environmental variables set up but still gets an error. You might need to remove and add the android platform to your project with the cordova CLI.

cordova platform rm android
cordova platform add android
Leo
  • 834
  • 8
  • 14