Error: Failed to find 'ANDROID_HOME' Environment variable

Asked

Viewed 8,830 times

1

I am beginner in mobile development and was studying IONIC, when I went to try to generate the test project apk gave the following error:

WARN: Ionic.project has been renamed to Ionic.config.json, Please Rename it. Running command: /home/lupum/Documents/testeionic/Hooks/after_prepare/010_add_platform_class.js /home/lupum/Documents/testeionic

add to body class: Platform-android

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.

I executed the command:

sudo ionic build android

And before that:

sudo cordova platform add android

I’ve been looking for ways to solve and found some that talked to change the PATH where I found ANDROID.

I executed the following commands:

export ANDROID_HOME=/</usr/local/android-studio/>/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools 

For my android found in: /usr/local/android-studio/

And the android platform on: ~/Android/Sdk/platform-tools$

Through this article: https://stackoverflow.com/questions/36198165/failed-to-find-android-home-environment-variable

The problem persists.

I would appreciate your help.

inserir a descrição da imagem aqui inserir a descrição da imagem aqui

Hello guys these are my directories, as it would be the correct way to set in the path ?

2 answers

4

That seems to be wrong:

export ANDROID_HOME=/</usr/local/android-studio/>/android-sdk-linux

The broker would probably be this:

export ANDROID_HOME=/usr/local/android-studio/android-sdk-linux

If the installation is in the user folder, you should use the absolute path (this seems to be your mistake), you made:

export ANDROID_HOME=Android/Sdk/tools/
export PATH="$PATH:Android/Sdk/platform-tools/"

And then:

export ANDROID_HOME=home/lupum/Android/Sdk

Note that both of you tried to use relative paths, which the environment variables will not be able to identify.

First these environment variables always need absolute paths, because if you do not do so they will not know what is relative

According to, absolute paths always begin with / (Linux, Mac, Like-Unix) and if it’s Windows always starts with C:, D:, etc..

So if you are sure that the installation is in this folder /home/lupum/Android/Sdk the path typed must be:

export ANDROID_HOME=/home/lupum/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Note that Linux and Mac are case-senstive, ie if the folder name has all minuscule letters and you type a letter in upper case it will not find, so type same as the one in the folder.

  • When I run the above commands it gives this error: WARN: Ionic.project has been renamed to Ionic.config.json, Please Rename it. Running command: /home/lupum/Documents/DOGIT/IONIC/Ionic-Bitcoins-master/Hooks/after_prepare/010_add_platform_class.js /home/lupum/Documents/DOGIT/IONIC/Ionic-Bitcoins-master add to body class: Platform-android Error: 'ANDROID_HOME' Environment variable is set to non-existent path: /usr/local/android-studio/android-sdk-linux Try update it Manually to point to Valid SDK directory.

  • Also I’ve gotten the update of Android SDK plus speaks that it is already in fact the newest version. So the error is another, also not permission believe.

  • @CRISLANIO I edited the answer, read again please.

0

To set up the Android development environment

Set the environment variable ANDROID_HOME based on the location of the Android SDK. Also, consider adding ANDROID_HOME/tools and ANDROID_HOME/platform-tools on your way.

Mac OS X

export ANDROID_HOME=/local-de-instalacao/android-studio/android-sdk-macosx
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Linux

export ANDROID_HOME=/usr/local/android-studio/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Windows

set ANDROID_HOME=C:\local-de-instalacao\android-studio\android-sdk-windows
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

For more details, see this article about Installing the Android Development Environment.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.