Where is android_sdk_root? and how do I set it.?
This is how I did it on macOS:
vim ~/.bash_profile # macOS 10.14 Mojave and older
vim ~/.zshrc # macOS 10.15 Catalina and newer (using zsh by default)
And added the following environment variables:
export ANDROID_HOME=/Users/{{your user}}/Library/Android/sdk
export ANDROID_SDK_ROOT=/Users/{{your user}}/Library/Android/sdk
export ANDROID_AVD_HOME=/Users/{{your user}}/.android/avd
Android path might be different, if so change it accordingly. At last, to refresh the terminal to apply changes:
source ~/.bash_profile # macOS 10.14 Mojave and older
source ~/.zshrc # macOS 10.15 Catalina and newer (using zsh by default)
I received the same error after installing android studio and trying to run hello world. I think you need to use the SDK Manager inside Android Studio to install some things first.
Open up Android Studio, and click on the SDK Manager in the toolbar.
Now install the SDK tools you need.
- Tools -> Android SDK Tools
- Tools -> Android SDK Platform-tools
- Tools -> Android SDK Build-tools (highest version)
For each Android release you are targeting, hit the appropriate Android X.X folder and select (at a minimum):
- SDK Platform
- A system image for the emulator, such as ARM EABI v7a System Image
The SDK Manager will run (this can take a while) and download and install the various SDKs.
Inside Android Studio, File->Project Structure will show you where your Android sdks are installed. As you can see mine is c:\users\Joe\AppData\Local\Android\sdk1.
If I navigate to C:\Users\Joe\AppData\Local\Android\sdk1\sources you can see the various Android SDKs installed there...
Open the terminal and run the command: nano $HOME/.bashrc aggregate the follow line:
export ANDROID_HOME=$HOME/Android/Sdk
export ANDROID_SDK_ROOT=$HOME/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Ctrl+o save and ctrl+x close.
And run the command:
source $HOME/.bashrc
echo $ANDROID_SDK_ROOT
MAC - one liner
echo "export ANDROID_HOME=~/Library/Android/sdk \
export ANDROID_SDK_ROOT=~/Library/Android/sdk \
export ANDROID_AVD_HOME=~/.android/avd" \
>> ~/.bash_profile && source ~/.bash_profile
android_sdk_root is a system variable which points to root folder of android sdk tools. You probably get the error because the variable is not set. To set it in Android Studio go to:
- File -> project Structure into Project Structure
- Left -> SDK Location
- SDK location select Android SDK location
If you have installed android SDK please refer to this answer to find the path to it: https://stackoverflow.com/a/15702396/3625900