Could anybody post a working solution for setting ANDROID_HOME
via the terminal?
My path to the Android-SDK is /Applications/ADT/sdk
.
Could anybody post a working solution for setting ANDROID_HOME
via the terminal?
My path to the Android-SDK is /Applications/ADT/sdk
.
Where the Android-SDK is installed depends on how you installed it.
If you downloaded the SDK through their website and then dragged/dropped the Application to your Applications folder, it\'s most likely here:
/Applications/ADT/sdk
(as it is in your case).
If you installed the SDK using Homebrew (brew cask install android-sdk
), then it\'s located here:
/usr/local/Caskroom/android-sdk/{YOUR_SDK_VERSION_NUMBER}
If the SDK was installed automatically as part of Android Studio then it\'s located here:
/Users/{YOUR_USER_NAME}/Library/Android/sdk
Once you know the location, open a terminal window and enter the following (changing out the path to the SDK to be however you installed it):
export ANDROID_HOME={YOUR_PATH}
Once you have this set, you need to add this to the PATH environment variable:
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Lastly apply these changes by re-sourcing .bash_profile:
source ~/.bash_profile
In Terminal:
nano ~/.bash_profile
Add lines:
export ANDROID_HOME=/YOUR_PATH_TO/android-sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
Check it worked:
source ~/.bash_profile
echo $ANDROID_HOME
Adding the following to my .bash_profile worked for me:
export ANDROID_HOME=/Users/$USER/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
quoting @user2993582\'s answer
export PATH=$PATH:$ANDROID_HOME/bin
The \'bin\' part has changed and it should be
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
I am having MAC OS X(Sierra) 10.12.2.
I set ANDROID_HOME to work on React Native(for Android apps) by following the following steps.
Added the following 4 lines to ~/.bash_profile.
export ANDROID_HOME=/Users/$USER/Library/Android/sdk/
export PATH=$PATH:$ANDROID_HOME
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
Finally execute the below command (or RESTART the system to reflect the changes made).
source ~/.bash_profile
That\'s it.
Could anybody post a working solution for doing this in the terminal?
ANDROID_HOME
is usually a directory like .android
. Its where things like the Debug Key will be stored.
export ANDROID_HOME=~/.android
You can automate it for your login. Just add it to your .bash_profile
(below is from my OS X 10.8.5 machine):
$ cat ~/.bash_profile
# MacPorts Installer addition on 2012-07-19 at 20:21:05
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Android
export ANDROID_NDK_ROOT=/opt/android-ndk-r9
export ANDROID_SDK_ROOT=/opt/android-sdk
export JAVA_HOME=`/usr/libexec/java_home`
export ANDROID_HOME=~/.android
export PATH=\"$ANDROID_SDK_ROOT/tools/\":\"$ANDROID_SDK_ROOT/platform-tools/\":\"$PATH\"
According to David Turner on the NDK Mailing List, both ANDROID_NDK_ROOT
and ANDROID_SDK_ROOT
need to be set because other tools depend on those values (see Recommended NDK Directory?).
After modifying ~/.bash_profile
, then perform the following (or logoff and back on):
source ~/.bash_profile
To set ANDROID_HOME
, variable, you need to know how you installed android dev setup.
If you don\'t know you can check if the following paths exist in your machine. Add the following to .bashrc
, .zshrc
, or .profile
depending on what you use
If you installed with homebrew,
export ANDROID_HOME=/usr/local/opt/android-sdk
Check if this path exists:
If you installed android studio following the website,
export ANDROID_HOME=~/Library/Android/sdk
Finally add it to path:
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
If you\'re too lazy to open an editor do this:
echo \"export ANDROID_HOME=~/Library/Android/sdk\" >> ~/.bashrc
echo \"export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools\" >> ~/.bashrc
People, note that if you will use ~/.bash_profile
then it will edit not your user\'s bash profile, but global. Instead go to your users directory (/Users/username) and edit it directly:
vim .bash_profile
And insert following two lines with respect to your Username and SDK directory
export PATH=$PATH:/Users/<username>/Library/Android/sdk/tools
export PATH=$PATH:/Users/<username>/Library/Android/sdk/platform-tools