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 variable named ANDROID_HOME.
But i don't know how to set this variable.
I am attaching screenshot to describe my problem correctly.
Open the terminal and type :
export ANDROID_HOME=/Applications/ADT/sdk
Add this to the PATH environment variable
export PATH=$PATH:$ANDROID_HOME/bin
If the terminal doesn't locate the added path(s) from the .bash_profile, please run this command
source ~/.bash_profile
Hope it works to you!
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=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
Reopen terminal and check if it worked:
source ~/.bash_profile
echo $ANDROID_HOME
The above answer is correct. Works really well. There is also quick way to do this.
- Open command prompt
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.
source ~/.bash_profile
export ANDROID_HOME=/YOUR_PATH_TO/android-sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
As a noob I was struggling a lot with setting up the variable.I was creating copies of .bash_profile files, the text in file was not saving etc ..😳
So I documented the the steps that worked for me. It is simple and foolproof( but little lengthy ) way to do it ✌🏼
Step1. Go to Finder >Go(on top) , click on users, then your user account you will see something like this :
{https://i.stack.imgur.com/8e9qX.png}
Step2. Now hold down ⌘ + ⇧ + . (dot) , this will now display hidden files and folders. It will look something like this:
{https://i.stack.imgur.com/apOoO.png}
PS: If the ⌘ + ⇧ +. does not work, please look up the keyboard shortcut relevant for your Mac Operating system name
Step3.
Scenario A :If .bash_profile
already exists
Step3.A.1 :Double click the .bash_profile. It should open up with TextEdit ( or alternatively right click >open with >TextEdit)
Step3.A.2 : Paste the variable text in the .bash_profile file using ⌘ + V
Step3.A.3 :Save the .bash_profile file using ⌘ + S
Scenario B :If .bash_profile
does NOT exist
This is kind silly way of doing it , but it worked perfectly for noob like me
Step3.B.1 : Download free BBEdit text editor which is pretty light weight. Whats special about this editor is that it lets you save file that starts with ". "
Step3.B.2 : Create a new file
Step3.B.3 : Save the file in your account folder . A warning will pop up , which looks something like this:
{https://i.stack.imgur.com/KLZmL.png}
Click Use"." button. Then the blank .bash_profile file will be saved
Step3.B.4 : Paste the variable text in the .bash_profile file using ⌘ + V
Step3.B.5 :Save the .bash_profile file using ⌘ + S
Step 4: Last and final step is to check if the above steps worked.
Open the bash and type echo $ANDROID_HOME
Your ANDROID_HOME variable should be now set.🤜🏻
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.
来源:https://stackoverflow.com/questions/28296237/set-android-home-environment-variable-in-mac