Phonegap failed to find ANDROID_HOME environment variable on Ubuntu

1.1k Views Asked by At

I followed up this Tutorial to install phonegap on Ubuntu, everything worked just fine I was even able to run the simulator .

But when I was trying to run my phonegap project on it I got this error :

[phonegap] executing 'cordova emulate android'...
cp: no such file or directory: /home/abdessalem/Documents/test/icon.png


Running command: /home/abdessalem/Documents/test/platforms/android/cordova/run --emulator

ERROR: 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: /home/abdessalem/Documents/test/platforms/android/cordova/run: Command failed with exit code 2

As the article saying I add my enviroment variable in ~/.profile

export ANDROID_HOME="/usr/local/android-sdk-linux"
export ANDROID_PLATFORM_TOOLS="/usr/local/android-sdk-linux/platform-tools"
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools   

How can I fix this ?

1

There are 1 best solutions below

7
On

You may need to

source ~/.profile

or logout and then back in

or you can simply enter the export commands before trying the cordova command

make sure the environment variables point to the correct locations in your system