Monday, April 5, 2010

Install and configure the Android SDK and the ADT Plugin for Eclipse

Software versions while writing this tutorial:
  • JDK: 6u19-1
  • Eclipse:Galileo Version: 3.5.2 Build id: M20100211-1343
  • Android SDK: 2.1, Revision 1 (January 2010)
  • ADT Plugin: 0.9.6 (March 2010) 
  • WST Server Adapters: 3.1.0.v200906020451-51DFAkF77g7GCNc    org.eclipse.wst.server_adapters.feature.feature.group
  • GEF Graphical Editing Framework: 3.5.2.v20100111-1352-787A47PpPBNpsWlH3EdWS1fY14Gn    org.eclipse.gef.all.feature.group

Before I post a Hello World tutorial, it is necessary to install and configure Eclipse, the Android SDK and the eclipse plugin.

1. Install the JDK 6:

     I'm using Arch Linux, so to install Eclipse is easy, just use pacman or Shaman(GUI), but first it is necessary to install JDK.

$ sudo pacman -S jdk

Password:

resolving dependencies...

looking for inter-conflicts...

:: jre conflicts with openjdk6. Remove openjdk6? [Y/n] y


Remove (1): openjdk6-6.b17_1.7.3-1

Total Removed Size:   124.62 MB


Targets (2): jre-6u19-2  jdk-6u19-1

Total Download Size:    70.00 MB

Total Installed Size:   246.64 MB


Proceed with installation? [Y/n] y

:: Retrieving packages from community...

 jre-6u19-2-i686.pkg...    25.3M  339.3K/s 00:01:16 [##################################################################################] 100%

 jdk-6u19-1-i686.pkg...    44.7M  341.3K/s 00:02:14 [##################################################################################] 100%

checking package integrity...

(2/2) checking for file conflicts                   [##################################################################################] 100%

(1/1) removing openjdk6                             [##################################################################################] 100%

(1/2) installing jre                                [##################################################################################] 100%

The jre package is licensed software.

You MUST read and agree to the license stored in

/opt/java/jre/LICENSE before using it.

(2/2) installing jdk                                [##################################################################################] 100%

The jdk package is licensed software.

You MUST read and agree to the license stored in

/opt/java/LICENSE before using it.


2. Install Eclipse:

    Now, to install eclipse is easy, just use pacman again.
    If you want to program C/C++ with eclipse, install eclipse-cdt too.
  

$ sudo pacman -S eclipse eclipse-cdt

3. Download the Android SDK here:
http://developer.android.com/sdk/index.html

    While I'm writing this tutorial, the SDK tools version is the revision 5, and the Android Platform is 2.1 (January, 2010).

    Save it where you like, but in my case I saved it in my home directory.
    Unpack it with this command or use some GUI:

$ tar -zxvf android-sdk_r05-linux_86.tgz

4. Modify your PATH enviroment:

    Another easy task when you are using Linux. Using your favorite text editor, open ~/.bash_profile or ~/.bashrc and locate a line like this:

PATH=$PATH:

    If it does not exist in both files create it like this:


PATH=$PATH:/home/<YOUR USERNAME>/android-sdk-linux_86/tools

    Open a terminal and type this command:

export PATH


4. Additional components necessary to ADT:

    In my case it was necessary to install other components before install the ADT plugin:
  1. Start Eclipse, then select Help > Install New Software.
  2. In the Available Software dialog, click Add....
  3. In the Add Site dialog that appears, enter a name for the remote site (for example, "GEF Update Sites") in the "Name" field. In the "Location" field, enter this URL:

    http://download.eclipse.org/tools/gef/updates/releases/


    Add another site:
    Name: Eclipse Updates
    Location: http://download.eclipse.org/eclipse/updates/3.5
    And another one:

    Add another site:
    Name: Galileo
    Location: http://download.eclipse.org/releases/galileo
    Click OK.
  4. Back in the Available Software view, search for: GEF and wst.
  5. Install them both.

    If you have done all of this without errors, it is time now to install the ADT plugin to eclipse.

5. ADT plugin for Eclipse:
  1. Start Eclipse, then select Help > Install New Software.
  2. In the Available Software dialog, click Add....
  3. In the Add Site dialog that appears, enter a name for the remote site (for example, "Android Plugin") in the "Name" field. In the "Location" field, enter this URL:

    https://dl-ssl.google.com/android/eclipse/


    Note: If you have trouble acquiring the plugin, you can try using "http" in the URL, instead of "https" (https is preferred for security reasons).
    Click OK.
  4. Back in the Available Software view, you should now see "Developer Tools" added to the list. Select the checkbox next to Developer Tools, which will automatically select the nested tools Android DDMS and Android Development Tools. Click Next.
  5. In the resulting Install Details dialog, the Android DDMS and Android Development Tools features are listed. Click Next to read and accept the license agreement and install any dependencies, then click Finish.
  6. Restart Eclipse. 

    This should be enough to start developing Android apps.

Next time: Adding some SDK Components and The Hello World.

    Sunday, April 4, 2010

    Syntax Highlighter to the web

        I was searching for a syntax highlighter to use in a IDE in the company where I work and I have found this web site:

    http://quickhighlighter.com/

        It is amazing, just select the language, paste your code and press the Highlight! button just bellow the code box.
        You will see how it is going to look like. If you like, press Toggle Code View and you will get the html code ready to use.

        There are some options at left side of the code box like if you want to show line numbers in your code...

    Renan