Set the ANDROID_HOME environment variable on your MacOS

Setting the environment variable is a configuration that we have to do in order for certain libraries and frameworks that we want to use to work; for example, in the case of Vue Native with Expo CLI, you will need this environment variable to be able to compile the application and use the Android SDK, and all this begins by reading said environment variable that we have to configure, so let's it.

Knowing which Shell you are using on Mac

First you have to know which shell you are using, since we have several, so, for that, the following command:

echo $SHELL

In my case it is:

/bin/zsh

So, according to the following table:

/bin/bash ->.bash_profile
/bin/zsh   -> .zshrc

I have to create/modify a file called:

.zshrc

The modification of the PATH is exactly the same in any of the shells that exist on MAC

What should be located inside your HOME, that is, the root of your user; this file will hold the PATHs you want to use; so, we have to add the same; for that you can use any editor such as vim, nano or another, in my case I am going to use vim, which is a text editor for the terminal; so:

vim .zshrc     

We press i to insert, and modify the PATH, which should look like the following:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH="$PATH:$ANDROID_HOME/platform-tools"

It is important that you check where the Android SDK is installed; it is generally installed in /Library/Android/sdk unless you specify otherwise.

Extra: Add more routes to your PATH

You probably need to add more elements to your PATH, in my case, for example Flutter, so to add more elements, just separate them by a colon (:); so:

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH="$PATH:/Users/andrescruz/development/flutter/bin:$ANDROID_HOME/platform-tools"

After you applied the changes, we saved and closed; for that, the following command

Escape

:wq!

First Escape to exit editing:

  1. : to set the command
  2. w to write
  3. what to go out
  4. ! to force exit

I am mentioning this problem because on Mac when you install your Vue Native with REACT NATIVE, it is possible that we get an error like the following if we DO NOT have our variable

ANDROID_HOME

Solution Couldn’t start project on Android: could not install *smartsocket* listener: Address already in use ADB server didn’t ACK en React Native

reactive run-android failed "could not install *smartsocket* listener: Address already in use"

As you can see, Expo CLI can't find the Android Command Line Tool (ADB) because it can't find the SDK in question; at this point, you can also try running in your terminal:

adb

And you should see an output like the following:

 

If it says something like, command not found, then you have problems with the above configuration.

- Andrés Cruz

En español

Andrés Cruz

Develop with Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz In Udemy

I agree to receive announcements of interest about this Blog.

!Courses from!

10$

On Udemy

There are 3d 01:43!


Udemy

!Courses from!

4$

In Academy

View courses

!Books from!

1$

See the books
¡Become an affiliate on Gumroad!