I am new in developing native app using Salesforce SDK. I tried to create android project from command line using forcedroid tool but there is problem in setting environment
To make it permanent on your system and the variable keep working after close the terminal, ou after a restart use:
nano ~/.bash_profile
Add lines:
export ANDROID_HOME=/YOUR_PATH_TO/android-sdk
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/tools/bin
export PATH=$PATH:$ANDROID_HOME/emulator
Reopen terminal and check if it worked:
source ~/.bash_profile
echo $ANDROID_HOME
Set the path of ANDROID_HOME > You have to open terminal and enter the below cmd.
touch ~/.bash_profile; open ~/.bash_profile
After that paste below paths in base profile file and save it
export ANDROID_HOME=/Users/<username>/Library/Android/sdk
export PATH="$JAVA_HOME/bin:$ANDROID_HOME/platform-tools:$ANDROID_HOME/emulator:$PATH"
If you try to run "adb devices" OR any other command and it says something like
zsh: command not found adb
It tells that you are using zsh shell and /.bash_profile won't work as it should. You will have to execute bash_profile everytime with source ~/.bash_profile
command when you open terminal, and it isn't permanent.
To fix this run
nano ~/.zshrc
Terminal image
and then paste following commands at the end of the file
export ANDROID_HOME=/Users/{YourName}/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export PATH=$ANDROID_HOME/tools/bin:$PATH
NOTE: You can find Android Home url from Android Studio > Preferences System Settings > Android SDK > Android SDK Location textbox
To save it, hit Ctrl + X, type Y to save and then enter to keep the file name as it is.
Restart the terminal and try your commands again.
Firstly, get the Android SDK location in Android Studio : Android Studio -> Preferences -> Appearance & Behaviour -> System Settings -> Android SDK -> Android SDK Location
Then execute the following commands in terminal
export ANDROID_HOME=Paste here your SDK location
export PATH=$PATH:$ANDROID_HOME/bin
It is done.
The above answer is correct. Works really well. There is also quick way to do this.
Type - echo export "ANDROID_HOME=/Users/yourName/Library/Android/sdk" >> ~/.bash_profile
Thats's it.
Close your terminal.
Open it again.
Type - echo $ANDROID_HOME to check if the home is set.
solved my problem on mac 10.14
brew install android-sdk