Wednesday, July 18, 2012

Eclipse+Android on Linux Mint 13 (Maya)

So far, my previous blogs on Linux Mint 13 has described how to install Java and the Android SDK. If you have followed the blogs, you will now be ready for the next step towards Android software development and that is to install a Java programming environment called Eclipse. Of course, first we have to install this (if it has not been installed yet). The install process is very simple - you can use either Synaptic or the command line to carry out this job.

  1. To use Synaptic, 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!

    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. Before you start Eclipse, you need to determine whether the necessary SWT (Standard Widget Toolkit) libraries link are set properly - else Eclipse will complain that it cannot start because it cannot find the swt library. Check the following location in you home directory for 32-bit Linux Mint by typing the following command in a terminal:

    ls ~/.swt/lib/linux/x86/

    For a 64-bit Linux Mint, the command is:

    ls ~/.swt/lib/linux/x86_64/

    If you see a message like that shown below, then the swt directory does not exist.

    ls: cannot access /home//.swt/lib/linux/x86/: No such file or directory

    To create the swt directory on a 32-bit Mint, execute:

    mkdir -p ~/.swt/lib/linux/x86/

    To create the directory on a 64-bit Mint, execute:

    mkdir -p ~/.swt/lib/linux/x86_64/

    On the other hand, if the swt directory exist, but nothing is listed (ie, no file links in that directory), then the necessary links are not set. if this is so, execute the following command:

    For 32-bit Mint:

    ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86/

    For 64-bit Mint:

    ln -s /usr/lib/jni/libswt-* ~/.swt/lib/linux/x86_64/

    Verify that the file links are set using the ls command again - if set, you should see the following file links:

    libswt-atk-gtk-3740.so    libswt-cairo-gtk-3740.so
    libswt-gnome-gtk-3740.so  libswt-pi-gtk-3740.so
    libswt-awt-gtk-3740.so    libswt-glx-gtk-3740.so
    libswt-gtk-3740.so        libswt-webkit-gtk-3740.so


  3. Start Eclipse, then answer the prompt (see below) 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 - then click OK.





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





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




  4. 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) - 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.

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

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







    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. In the next window, you'll see a list of the tools to be downloaded (see below) - click Next. Read and accept the license agreements (see below), then click Finish. The plug-ins will be downloaded and installed.









    NOTE: 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. When you arrive at the main workbench, you will see a window (see below) welcoming you to Android development - here you will have to configure the Android SDK.





    Since we have already downloaded and installed the Android SDK (see my previous blog), all we need to do here is specify the location of the SDK which happens to be '/home/<username>/android-sdk-linux'. Then click 'Next' - the next screen (see below) will ask you whether you want to contribute to Google's usage statistics - select 'Yes' or 'No' and then press 'Finish'



That's it - you are now ready to start developing Android software on your Linux Mint 13. 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.

5 comments:

  1. Everything went smoothly until I got to this step, "At the end of this process, you will be prompted to restart Eclipse - do so. When you arrive at the main workbench, you will see a window (see below) welcoming you to Android development - here you will have to configure the Android SDK."

    When Eclipse restarted, I was not asked to configure the SDK and I can't figure out how to manually configure it within Eclipse.

    Any recommendations on what I can do to configure the SDK?

    In addition, shouldn't the graphic for configuring the SDK show the "Use Existing SDK" be selected rather than the "Install New SDK" radio button?

    Thanks

    ReplyDelete
    Replies
    1. Yes, the screen-shot graphics should show the "Use Existing SDK" be selected rather than the "Install New SDK" radio button. I will be updating the various blogs on Android development soon to refect recent changes and I will make sure, this time, that the screen-shots are done properly.

      Thanks you for your feedback.

      Delete
  2. An update to my previous post... I was able to get around my issue by doing the following:

    1. cd ~/.eclipse
    2. rm -rf *
    3. eclipse&

    When I re-launched eclipse, I was asked to configure the SDK, I selected "Use Existing SDK", and pointed to the version that I had manually installed based on your previous blog post.

    I'm not sure what it was that messed up in the .eclipse area, but since this was a new install, it really didn't matter. So I felt safe blowing it away.

    Thanks

    ReplyDelete
  3. I had to add http://download.eclipse.org/releases/indigo to the Available Software in order to get it to work at the step where you install the Developer Tools.

    ReplyDelete