Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to run Android project using Maven in Mac 10.7.4, for that I need to set environment and path variables.

This are the steps I need to follow to run android using Maven

Maven 3.0.3+ installed,

Set environment variable ANDROID_HOME to the path of your installed Android SDK and add $ANDROID_HOME/tools as well as $ANDROID_HOME/platform-tools to your $PATH. (or on Windows %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools).

MacOS users: Note that for the path to work on the commandline and in IDE's started by launchd you have to set it in /etc/launchd.conf and NOT in .bashrc or something else

But I am very new to OS X so I don't know how to set it. I seen this post but I get stuck in Step 4, saving the etc/launchd.conf file after entering the paths.

  • How do I set environment variables globally?

  • What do I need to open, edit, save the etc/launchd.conf file?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

Do you actually need system-wide variables? If variables in your user environment would suffice you could create a directory ~/.MacOSX and a file environment.plist in it, in case one of them doesn't exist, and then add your variables to environment.plist.

mkdir ~/.MacOSX
touch ~/.MacOSX/environment.plist
open ~/.MacOSX/environment.plist

Log off and back on for the changes to become active.

share|improve this answer
    
Thanks for your answer.. I don't think so. I will try environment.plist file. If could could you update how to add and save path to that file. Sorry i am very new to Mac] –  Vino Oct 1 '12 at 11:28
    
The command open ~/.MacOSX/environment.plist should open the file with the default application (normally the plist editor). –  Ansgar Wiechers Oct 1 '12 at 12:26
    
Yes i done that but i dont think it get added because while running my maven project it says Please provide a proper Android SDK directory path as configuration parameter <sdk><path>...</path></sdk> in the plugin <configuration/>. As an alternative, you may add the parameter to commandline: -Dandroid.sdk.path=... or set environment variable ANDROID_HOME. -> [Help 1] –  Vino Oct 1 '12 at 12:28
    
Did you log off and back on after adding the variables? –  Ansgar Wiechers Oct 1 '12 at 12:31
    
Thanks that error has been removed now –  Vino Oct 1 '12 at 12:48
add comment

You can use any editor to change the /etc/launchd.conf file, you don't have to use vi or vim.

Since you need superuser privileges to edit the file, you cannot simply run TextEdit. What you can do however is to open a Terminal and enter:

sudo touch /etc/launchd.conf
sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/launchd.conf

Now, TextEdit will open /etc/launchd.conf. Make your changes as explained in this Stack Overflow answer you mentioned. Make sure to replace the highlighted part with the actual path to your Android SDK, also changing your username.

setenv ANDROID_HOME /Users/your-username/Documents/android-sdk/

Now save the file as usual through File » Save or CmdS.

A reboot might be necessary.

share|improve this answer
    
Thanks for your answer slhck.. It helps when i use your first command it says launchd.conf file not found.. If possible could you update how to create as well. Many thanks –  Vino Oct 1 '12 at 12:05
    
See my update to the question. –  slhck Oct 1 '12 at 12:47
    
Done that slick, now it says The document “launchd.conf” could not be opened. You don’t have permission. –  Vino Oct 1 '12 at 12:50
    
No, that can't be. Make sure to run both commands with sudo. –  slhck Oct 1 '12 at 12:52
    
yes both commands are with sudo slhck –  Vino Oct 1 '12 at 12:56
add comment

You could also just open terminal and type launchctl

then setenv <key> <value>

which in your case woud be setenv ANDROID_HOME /path/to/whatever

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.