Set ANDROID_HOME environment variable in mac

后端 未结 17 799
梦谈多话
梦谈多话 2020-12-04 07:36

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

相关标签:
17条回答
  • 2020-12-04 08:04

    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
    
    0 讨论(0)
  • 2020-12-04 08:08

    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"
    
    0 讨论(0)
  • 2020-12-04 08:08

    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.

    0 讨论(0)
  • 2020-12-04 08:12

    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.

    0 讨论(0)
  • 2020-12-04 08:15

    The above answer is correct. Works really well. There is also quick way to do this.

    1. Open command prompt
    2. Type - echo export "ANDROID_HOME=/Users/yourName/Library/Android/sdk" >> ~/.bash_profile

      Thats's it.

    3. Close your terminal.

    4. Open it again.

    5. Type - echo $ANDROID_HOME to check if the home is set.

    0 讨论(0)
  • 2020-12-04 08:15

    solved my problem on mac 10.14 brew install android-sdk

    0 讨论(0)
提交回复
热议问题