Error: Failed to find 'ANDROID_HOME' environment variable

1

I am a beginner in mobile development and was studying IONIC, when I was trying 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 updating your 'PATH' to include path to valid SDK directory.

I ran the command:

sudo ionic build android

And before that:

sudo cordova platform add android

I've been looking for ways to solve and I've found some that talked about changing the PATH from where I found ANDROID.

I ran the following commands:

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

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

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

Through this article: link

The problem persists.

I would appreciate it if I could help.

Hello everyone, these are my directories, what would be the correct way to set them in path?

    
asked by anonymous 08.01.2017 / 18:59

3 answers

2

This 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 must use the absolute path (this seems to be your error), you did:

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

And then:

export ANDROID_HOME=home/lupum/Android/Sdk

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

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

Absolute paths always begin with / (Linux, Mac, Like-Unix) and if it is Windows always start with C: , D: , etc.

So if you are sure that the installation is in this folder /home/lupum/Android/Sdk the path you typed should 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-sensitive, that is, if the folder name has lowercase letters and you type a capital letter it will not find it, then type the same as the one in the folder.

    
08.01.2017 / 19:16
0

To configure 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 to your path.

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, here is an article on Installing the Android Development Environment < sup> (en) .

    
08.01.2017 / 19:26
-1

In the file .bashrc I added the following lines to the end of the file.

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

The error still remains.

  

Error: Failed to find 'ANDROID_HOME' environment variable. Try setting   setting it manually. Failed to find 'android' command in your 'PATH'.   Try updating your 'PATH' to include path to valid SDK directory.

    
16.01.2017 / 15:24