Tuesday, November 15, 2011

How to setup Android Development Environment on Mac




Setting up the develop environment for Android is little tricky in MAC OS. To setup development environment in Mac OS for android, follow the below steps -




Android SDK installation:

  • First need to download the Android SDK from http://developer.android.com/sdk/index.html. [Note: download the MAC OS sdk from the list.]
  • Unzip the downloaded sdk and copy this in some location into your local drive. I am copying into /Applications, so my path will become "/Applications/android-sdk-macosx/".
  • Add the JAVA_HOME, ANDROID_SDK, PATH, and NO_NEON into .bashrc file. To add these entry into your .bashrc file follow the below steps:
    • First check if the file is exists, open Terminal.app (in Applications/Utilities) and type "ls -a ~/" This will list all of the file in your home directory. If .bashrc exists, then you can edit the file by typing "open -a /Applications/TextEdit.app .bashrc".
    • If the file doesn't exist, then open TextEdit, select Format=>Make Plain Text, then paste in the necessary commands. Once that's done, go to File=>Save As, uncheck "If no extension is provided, use ".txt", type in the name ".bashrc", and save the file. TextEdit will warn you that files beginning with a "." are reserved for the system. Click the "Use '.'" button. Note: Remember to save this on your home location. 
    • Add Following entries into your .bashrc file -

                     export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
                     export ANDROID_SDK=/Applications/android-sdk-macosx/
                     export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
                     export NO_NEON=1

    • Details about above configuration -
      • Some Mac OS comes with the 64bit version of Java 1.6 installed by default. so we are setting the JAVA_HOME to point at it.
      • The PATH is not required alias but will make it easy for you to run the Android SDK Manager by typing “android” or the Android Debug Bridge by typing “adb” in the Terminal.
      • Set NO_NEON to prevent Android compilation from using the Neon CPU enhancements which are not supported on all Android devices (including the Emulator).
  • Run Android SDK manager to install support for one or more Android OS platform versions. [Not mandatory to install all versions, but at least one version will require to proceed with the further steps.] To install run the $ANDROID_SDK/tools/android command and select at least one sdk and API version. It might take some time depending upon your selection.

Android NDK installation:

          The Android NDK is a toolset that lets you embed components that make use of native code in your Android applications.
  • Download Android NDK from http://developer.android.com/sdk/ndk/index.html. [Note: Download the MAC OS version from the list]
  • Unzip the downloaded ndk and copy this into some location into your local drive. I am copying into /Applications, so my path will be "/Applications/android-ndk-r7".
  • Add below entries into your .bashrc file - 
          export ANDROID_NDK=/Applications/android-ndk-r7
          export PATH=$PATH:$ANDROID_NDK:$ANDROID_NDK/tool

Android Eclipse Plugin installation (ADT):
  • Start Eclipse.
  • Click on Help-->Install New Software.
  • Put https://dl-ssl.google.com/android/eclipse/” into the “Work with:” field.
  • Press Enter, check the below table will populate automatically with the options.
  • Check the Developer Tool check box to select all.
  • Click Next, Next and select the Accept agreement And Finish.
  • Once it will finish the installation, It will ask you for the restart, so click on Restart Now to restart eclipse.
Android Eclipse Plugin Configuration (ADT):

         Once Eclipse restarted, We need to configure the installed ADT plugin.
  • Goto Eclipse-->Preferences menu.
  • Select Android from the left side list.
  • Put your $ANDROID_SDK location into SDK Location field. In my case it's "/Applications/android-sdk-macosx"
  • Click on Apply button and you will see all the android platform versions which you had installed before.
  • Hit OK, and now your Android development environment is all setup correctly. 
********** Create Hello world app to start with ***************



No comments:

Post a Comment