Friday, December 14, 2012

Eclipse+Android on Ubuntu 12.04 (Part 2)

This is the second part to my blog on installing and using Eclipse as the Java programming environment. It does not use the Google ADT - instead you either have Eclipse from Ubuntu's repository already installed or you choose to install Eclipse from Ubuntu's repository instead of the Google ADT.

If you have already installed Eclipse from Ubuntu's repository, you now have to configure Eclipse to use the Google ADT. Skip step 1 below and start at step 3. On the other hand, if you have not installed Eclipse from Ubuntu's repository, start at step 1.

I hope that you do have Synaptic installed on your system - if not, install it now by opening a terminal and executing:

  sudo apt-get install synaptic

  1. To use Synaptic to install Eclipse from Ubuntu's repository, start Synaptic, enter your password, then type 'eclipse' into the search box. The entry for Eclipse will appear - mark it for installation, and the rest of the additional items, and then click on the 'Apply' button. Wait for download and install process to finish, close Synaptic and you are done! Skip the instructions below and proceed directly to 2.

    To use the command line, start a terminal, and type:

      sudo apt-get install eclipse

    Type 'Enter' when prompted, wait for the packages to be downloaded and installed, close the terminal and you are done!

  2. Start Eclipse for the first time by clicking on the dash, then entering 'eclipse' in the search box, and finally clicking on the icon for Eclipse that will appear.

    Eclipse will start and a window will pop-up (see below) asking you to set a workspace - I use '/home/(username)/Projects/Android (where username is your login name) but you can place it anywhere you like or accept the default of /home/(username)/workspace. You can also set this as the default and not ask again - then click OK.

    Workspace Launcher

    Eclipse will start loading and you will then see a Welcome screen like the one shown below.

    Welcome screen

    Click on 'Workbench' (near top right corner of the screen) and the main workbench screen will appear (see below).

    Main workbench screen

    You can, at this stage, right-click on the Eclipse icon in the dock and select 'Lock to Launcher'. This way Eclipse can be easily started any time by clicking on that icon.
  3. Click on Help (on the top menu bar), then on select 'Install New Software'. A new window called 'Available Software' will pop-up (see below)

    Available Software window

    Click the ‘Add’ button at the top of the window. An “Add Repository” window will pop up. Pick a name, (I chose ‘ADT Plugin’ - ADT stands for Android Development Tools), then enter the following URL in the ‘Location’ box and click OK.

    Note: If you have trouble acquiring the plugin, try using "http" in the URL, instead of "https". For security reasons, https is preferred.

    Add Repository window

    The window will close and a 'Pending' message will appear on the Available Software window - this indicates that the software is checking the URL for the plug-ins. When this is complete, you will see the 2 items listed (see below). Select the checkbox next to Developer Tools and click Next.

    Available Software entries

    In the next Install Details window, you'll see a list of the tools to be downloaded (see below) - click Next.

    Install Details window

    Read and accept the license agreements (see below), then click Finish. The plug-ins will be downloaded and installed. Click OK if you get a security warning saying that the authenticity or validity of the software can't be established. At the end of this process, you will be prompted to restart Eclipse - do so.

    Review Licenses window

    Downloading and installing plugins

    Security Warning

    Restart notice

    When you arrive back at the main workbench, you will see a window (see below) stating that location of the Android SDK has not been setup - click on the 'Close' button. You will set the location of the Android SDK next. On the Welcome to Android Development window (see below), click on the 'Use existing SDKs' button and then browse to the location of the SDK which happens to be '/home/(username)/android-sdk-linux-x86' - then click on Finish. You will then be back at the main workbench.

    Android SDK location not set

    Set Android SDK location

    Note that an error message (Sending Tracking request failed!) may appear in the Console part of Eclipse (see below). This is known bug which has been reported but it does not seem to be harmful to Android software development on Eclipse - so, for the time being, just ignore the message.

    Eclipse console message

    One last thing - if you open Eclipse's Windows menu, you will not find the SDK Manager and the AVD Manager there. Also, there is no Run button on the toolbar. To make Android programming with Eclipse easier, configure it by clicking the Window menu item, followed by clicking on the Customize Perspective... item. The Customize Perspective - Resource window will open as shown below.

    Customize Perspective - Resource

    Click on the Command Groups Availability tab and place a check mark on the Android SDK and AVD Manager item as shown. Also scroll down on the 'Available command groups' and place a check mark on the Launch item as shown below. Then click OK.

    SDK and AVD Managers selected
                                                   Launch selected

    If you now open the Window menu, you will find both the Android SDK Manager and the Android Virtual Device Manager listed there. You will also find the 'Run' button in the Eclipse toolbar.
That's it - you are now ready to start developing Android software on your Ubuntu 12.04. My next blog will show you a simple 'Hello, World' project, a few sample projects and will also describe some of the resources you can use to start program development on Android.

No comments:

Post a Comment