16
Nov/08
1

Where to install Eclipse on Ubuntu

If you’re like me, accustomed to installing most packages via Ubuntu’s package manager, you might be a bit confused as to where to install Eclipse since it should be in a place thats accessible by every user on your system.  Sure you can install it in your user home directory but that wouldn’t be very tidy.

I extracted part of these instructions from: http://flurdy.com/docs/eclipse/install.html

These instructions assume you’ve downloaded and extracted the Eclipse tarball:

sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo mv eclipse /opt/eclipse cd /opt sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
sudo chmod +x `sudo find eclipse -type d`

Then create an eclipse executable in your path

sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse

sudoedit /usr/bin/eclipse

With these contents:

#!/bin/sh
export ECLIPSE_HOME=”/opt/eclipse”
$ECLIPSE_HOME/eclipse $*

Now you can execute Eclipse from anywhere in your bash shell. Check out the original article for generating a desktop icon. In the tarball I downloaded, it didn’t come with the icon.xpm that contains the Eclipse icon but no worries for me.

The take-home lesson here is that /opt is meant as a place to install application software packages. The topic is Filesystem Heirarchy Standard (FHS) .. these folks seem to be the standard authority on it:

http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES

However it’s not to say that this standard is the most progressive one we have today.  I found GoboLinux to be particularly interesting: http://en.wikipedia.org/wiki/GoboLinux#The_GoboLinux_hierarchy

16
Nov/08
10

Installing Eclipse IDE and Android SDK on Ubuntu 8.10

This blog gives pointers on getting the Android development environment working on a base Ubuntu 8.10 installation.

This assumes you’re familiar with google’s installation instructions (see http://code.google.com/android/intro/installing.html) and might still be having some problems.

This also assumes you’ve installed Sun JDK 1.6.

So here are some tips and gotcha’s:

  • Don’t install Eclipse with Ubuntu’s package manager. At time of writing, Eclipse 3.2.2.2 is in the distro. Make you sure have the latest Eclipse version by downloading directly from Eclipse’s site. See http://www.eclipse.org/downloads/
  • With most (if not all) base Ubuntu installations, java-6-openjdk or java-gcj is used, not Sun’s JDK. You don’t want to uninstall java-6-openjdk either because other apps in your system will be uninstalled along with it. In your Ubuntu filesystem, JVM tools (e.g. javac, javah, javadoc, java) are actually symlinks to the actual JDK. So what you want to do is update these symbolic links. There are at least 2 tools I’ve come across to help do this. I found the following:
  • sudo update-alternatives –config java
  • sudo galternatives
  • In Eclipse, for some reason I’ve not been able to add the ADT plugin via add site.  I had to download the SDK zip file and install as a local archive.
  • If you don’t know where to install Eclipse, check out my post on where to install eclipse since we’re not using the comfy package manager to take care of things for us. ;)

That’s it for now.

6
Nov/08
12

Getting Android emulator working with Google Maps API Key

I was trying to get an Android app that uses Google Maps API to display a MapView running on the emulator.  It took quite a bit of hair pulling to finally get it working.

First, I tried using a self-signed keystore instead of the the debug.keystore provided through the Android SDK.  I created my keystore using keytool -genkey from JDK.  Then I switch the app from using the default, debug.keystore, to my-new-self-signed.keystore.  Using keytool -list, I got the MD5 of the certificate that is needed to obtain a Google Map API key.  Then the API key was put into the MapView android:apikey attribute.  When I brought up the app in the emulator, I got a blank map grid screen.  The reason I wanted to use the self-signed keystore instead of the debug keystore is so I don’t have to obtain a new Map API key and change the code to reflect this upon releasing the app.

So, I decided to go with the debug.keystore and that worked fine.  Here is what I had to do.

  1. $ keytool -list -alias androiddebugkey -keystore <path_to_debug_keystore>.keystore -storepass android -keypass android
  2. Copy that MD5 and goto http://code.google.com/android/maps-api-signup.html
  3. Signup for an API key
  4. In my xml file that has the views for the activity, add
    <com.google.android.maps.MapView
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:enabled="true"
     android:clickable="true"
     android:apiKey="example_Maps_ApiKey_String"
     />
  5. In the Manifest.xml file, add the permissions needed
    <uses-permission android:name=”android.permission.INTERNET”></uses-permission>
    <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission>
  6. In the Manifest.xml file, add the maps library
    <uses-library android:name=”com.google.android.maps” />
    within the application tag
  7. The entire Manifest.xml looks like this
    <?xml version=”1.0″ encoding=”utf-8″?>
    <manifest xmlns:android=”http://schemas.android.com/apk/res/android”
    package=”com.informationideas.mapapp”
    android:versionCode=”1″
    android:versionName=”1.0.0″>
    <uses-permission android:name=”android.permission.INTERNET”></uses-permission>
    <uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission>
    <application android:icon=”@drawable/icon” android:label=”@string/app_name”>
    <uses-library android:name=”com.google.android.maps” />
    <activity android:name=”.ShowDesktop”
    android:label=”@string/app_name”>
    <intent-filter>
    <action android:name=”android.intent.action.MAIN” />
    <category android:name=”android.intent.category.LAUNCHER” />
    </intent-filter>
    </activity>
    </application>
    </manifest>
  8. The default activity file should look like this

    package com.informationideas.mapapp;
    import android.os.Bundle;
    import com.google.android.maps.MapActivity;

    public class ShowDesktop extends MapActivity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    }

    @Override
    protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
    }
    }

Now off to building cool things with the map!