Cordova run android : ANDROID_HOME not set and android not in my path

32,102

Solution 1

I answer me !

My solution :

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

Remove and add platform

Solution 2

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!

Solution 3

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.

Solution 4

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)

Share:
32,102
Sorcim
Author by

Sorcim

Updated on July 11, 2022

Comments

  • Sorcim
    Sorcim almost 2 years

    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
    
  • formica
    formica over 8 years
    It was sufficient to set the PATH for me