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

Hi,

I can’t build my project for Android, when I use:

sudo ionic build android 

I get this error:

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

I have Android SDK installed and ANDROID_HOME defined.

echo $ANDROID_HOME

Returns the folder of my android sdk correctly:
/home/joseba/Descargas/android-sdk-linux

Also if i do anywhere in the console:

android

Show android sdk window.

I installed Android 5.1.1 (API 22), all extras and build tools.

In cordova I can do “cordova build” and no error happend.

Any help will be apreciated. Thanks in advance!

Why do you use sudo?
It should not be required.

Could it be that ANDROID_HOME and PATH are set for your user and not for root user.