How To Set Android_sdk_root In Mac?
Solution 1:
vim ~/.bash_profile
Then add the following environment variables:
exportANDROID_HOME=~/Library/Android/sdk
exportANDROID_SDK_ROOT=~/Library/Android/sdk
exportANDROID_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:
exportANDROID_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.
Post a Comment for "How To Set Android_sdk_root In Mac?"