Search code examples
androidmacosenvironment-variablessystemcommand-prompt

How to set the environmental variable for SDK on MAC machine


In MAC machine, I setup the environmental variables for ANDROID SDK

Opened the terminal & entered the following commands

 export ANDROID_HOME=/Applications/android-sdk-macosx export
 PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

In the terminal I verified the path by typing export

PATH

In the above image, the PATH is appended with some other values whether those appended value is the issue or not?

Then, When I try to run it from eclipse, an error message is displayed like Console Error

A new session could not be created. (Original error: Could not find adb. Please set the ANDROID_HOME environment variable with the Android SDK root directory path.) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 350 milliseconds

Suggestions and comments are welcome.


Solution

  • I set those environmental as System-wide environmental variables. and it works now.

    Previously I didn't set the environmental variable(ANDROID_HOME) as system-wide variable, that is the reason why the ANDROID_HOME variable is invisible in Eclipse Environment settings.

    To set the ANDROID_HOME as System-wide environmental variable, I have used the following commands in terminal and some settings in Eclipse.

    Terminal:

    Run sudo nano /etc/launchd.conf
    Add setenv ANDROID_HOME /Users/selvakumar/Documents/android-sdk-macosx
    Then either restart or run launchctl < /etc/launchd.conf; sudo launchctl < /etc/launchd.conf
    

    Eclipse:

    Then the variable becomes visible in the Eclipse--> Run Configurations--> Environment -->Select-->ANDROID_HOME then I checked the ANDROID_HOME variable and click apply. Run the code with your new Run configuration settings. That made my code to work.