Search code examples
androidmacoscordovaandroid-sdk-manager

How to install ANDROID_SDK_ROOT on Mac OS?


Good day. I can not understand how to install ANDROID_SDK_ROOT variable for the Mac OS.

Search on stackoverflow already made, the code on recommendations tried to use - nothing.

I installed Android Studio by standard, my SDK has path /Users/admin/Library/Android/sdk/

vim ~/.bash_profile

export ANDROID_HOME=/Users/admin/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/admin/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/admin/.android/avd

source ~/.bash_profile

When you try to build an application in Cordova the same result:

Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/admin/Library/Android/sdk (DEPRECATED)
Requirements check failed for JDK 8 ('1.8.*')! Detected version: 13.0.1
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.

Solution

  • First, after configuring your .bash_profile be sure to open a new terminal session so the environmental variables get picked up.

    Assuming you've tried that already, you may want to consider installing the Android development kit through Homebrew - a package manager for MacOS. Once you have everything set up there, you can then run

    $ brew install gradle

    $ brew install android-sdk

    Homebrew will then add the appropriate variables to your .bash_profile

    If that all still proves to be of no avail, try setting your JAVA_HOME variable to be:

    export JAVA_HOME="$(/ur/libexec/java_home -v 1.8)