How to set ANDROID_SDK_ROOT in mac?
Solution 1
vim ~/.bash_profile
Then add the following environment variables:
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_SDK_ROOT=~/Library/Android/sdk
export ANDROID_AVD_HOME=~/.android/avd
Android path might be different, if so change it accordingly. At last, to refresh the terminal to apply changes:
source ~/.bash_profile
Solution 2
Since you used Homebrew, you can add this to your path:
export ANDROID_SDK_ROOT=/usr/local/share/android-sdk
Hope I helped! :D
Solution 3
I was facing similar problem. I already downloaded Android SDK as well as Android studio so there were two paths of Android Home. To run emulator and remove error of Android sdk root not set use below steps.
- Set the path of android sdk which is downloaded by Android Studio.
- If you already have SDK downloaded in sdk folder copy them in Android studio generated folder. /Library/Android/sdk
Set the bash profile and add paths as shown below.
export ANDROID_HOME=/Users/{your pc name}/Library/Android/sdk export ANDROID_SDK_ROOT=$ANDROID_HOME
Solution 4
Update 2021
If you are a hybrid cordova/ionic/react app developer. Here's what worked for me. All the other answers failed. So i'm sharing my answer
1. Find the correct JAVA_HOME path on your machine
/usr/libexec/java_home -V
2. Copy that path associated with "Java SE 8" which usually looks like /Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home
3. create a ~/.bash_profile
or ~/.zshrc
file. Here I'm using touch because I dislike nano or vim in the terminal. touch is a regular text editor which I'm more comfortable editing with. Use whatever you like.
touch ~/.bash_profile;
touch ~/.zshrc;
4. edit and copy/paste this in your ~/.bash_profile
or ~/.zshrc
file
export PATH=$PATH:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=/Users/user198559/Library/Android/sdk
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
5. Save your file with file->save like you would save any regular file, after that write this in your terminal
source ~/.bash_profile;
source ~/.zshrc;
6. check if path variables are set correctly by opening new terminal
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
echo $ANDROID_SDK_ROOT
/Users/user198559/Library/Android/sdk
echo $ANDROID_HOME (deprecated)
(should return empty)
Solution 5
Today I had the same problem with ionic framework. First, I checked in AVD manager in Android Studio(tools->Android) that all devices run and it was one device without api version. So I changed and test the device. Then i run ionic emulate again and works fine. Also, you could use --target=Device_Name to run a specific device.
Mayur Tolani
Updated on February 05, 2022Comments
-
Mayur Tolani over 2 years
I am trying to use Cordova for app development. For now I am focusing on Android. I am trying to run
cordova emulate android
. It runs and after a long list of packages it says ‘build sucessful’ but in the end it also saysPANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT
I use Homebrew. Here is output of the command on the command line:
BUILD SUCCESSFUL Total time: 1.345 secs Built the following apk(s): /users/mayurtolani/myMobileApp/platforms/android/build/outputs/apk/android-debug.apk ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1 JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home No emulator specified, defaulting to Nexus_5_API_24 Waiting for emulator to start... PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT