Saturday, 6 November 2010

Google Maps in Android (emulator)

In order to get google maps in your apps and so build location-based services, your must register with Google, and include a key that they'll provide against a MD5 string that you get from your own system. If you're like me, just developing and debugging without deploying your apps, you'll need one key called "", another one will be used to comercially deploy your apps.

I've done that using Eclipse, so here it goes. Locate your .android folder, on Ubuntu/Linux, that's in ~/.android, it's a hidden file, (hence the dot .android, type ls -a for hidden files), on Windows 7, its location is at C:\Users\\.android. This file contains a digital certificate that is going to be used to create the MD5 string. You need Keytool in Eclipse, Eclipse is the "does it all for you" and is getting really powerful so if you're concerned with efficiency in producing code, Eclipse is the main thing.
To install keytool, once again go to the Help menu, install new software (in Helios), click add for a new repository, add, (check, then follow the usual procedure to install plugins in Eclipse.

Once installed, they'll be a menu called keystore, choose open keystore, browse to the "" in the .android folder, and type "android" as password. It took me a while to find the password ... In the lower part of eclipse, where the console usually is, select the keytool tab if it's not already, double click on "androiddebugkey", the certificate should open and the MD5 Fingerprint displayed. Copy it and go to Maps API Key Signup -, you need a valid Google account for that, accept their terms and conditions, and paste the key where it says so. It should give you back the key to insert in your code. That's in your project folder in Eclipse, open main.xml located in the res then layout folder and where it says apiKey, insert it. Now theoretically, it should display a Google map in your app. And it does!

Your main.xml should look like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""

android:apiKey="Your API Key" />

Eclipse + Android

Android SDK Intallation Log

In order to run the Android SDK - Software Development Kit and start writing code in Eclipse, you must download the SDK at, android-sdk_r07-linux_x86.tgz for linux, i386, there's no 64 bit version as it seems. The file must be extracted from the .tgz file and placed in its due location, in my case that's /usr/local/bin/. Again, as with the Java JDK, add the location of the Android folder to the path.
Next, from within Eclipse, mine is Eclipse Helios, you must install the ADT plugin for Eclipse, so choose the help menu, then install new software, click then the add button to add a repository, something like Android plugin for the name and for the location. Select the check box next to Developers tools and start with the installation.
Once it's installed, it needs to be configured. Select Window->Preferences then Android from the left panel. Update the location of your Android folder by clicking Browse. It should now know where to locate all the necessary class files to start developing.
Last thing to do, select the help menu, go to Android SDK and AVD Manager, then click on the available packages to get the Google APIs that you might need. Select the ones that are relevant for your work, in my case, I'll stick for now to the latest version of Google API, i.e. version 8, you should that in order to run on older versions of Android, your app should be tested on the previous APIs, and thus downloaded now. I haven't got to that part since I'm not comercialising my software (for now), so I'll skip for later on, I feel nonetheless, that it wont't be easy to make it work on all the previous platforms.
After installing the API, all should be ready now to code your first Android app.

Nota: To run it under Linux 64bit, you need to install the ia32-libs package using apt-get:
apt-get install ia32-libs (Ubuntu 10.10LTS 64bit)

Friday, 5 November 2010

Eclipse Installation Log

I've downloaded eclipse-jee-helios-SR1-linux-gtk-x86_64.tar.gz from the Eclipse website, that is Eclipse Helios last version up to date.
As I forgot to install the Java Devolopment Kit (JDK), I pointed to Sun's website (pardon me, Oracle's brand new machine) and got JDK 6 Update 22 (Java SE Development Kit 6u22), after chosing Linux 64 bits, which lead to jdk-6u22-linux-x64.bin.
I've moved the binary file to /usr/local/bin/, and eclipse's as well. I'm running Ubuntu 10.04 LTS on Virtual Box.
As sudo, I've run the Java script, that's ./jdk-6u22-linux-x64.bin at the prompt. It started to decompress and finally created everything in a folder called jdk1.60.22. Next step the always tricky part of setting the path to the Java home in the PATH. So sudo (whatever editor you use, I might Vim), that's sudo vim ~/.bashrc (bashrc is a hidden file in your home directory and configure the shell environment, you need to type ls -a in order to see it). At the end of the file, I've inserted:
export JAVA_HOME=/usr/local/bin/jdk1.6.0_22
export PATH=$JAVA_HOME/bin:$PATH

When I type at the prompt, echo $PATH the JAVA_HOME is appended. I took me a while.
Problem: Eclipse wouldn't launch, it was giving a error saying no Java virtual machine found. After some digging, (online digging?!) I've come up to this site and this one at Following instructions, I altered a file called Eclipse.ini in the Eclipse folder. I just added two lines:
the whole file looks like this:

Just added a launcher on my desktop and that it, it works. It sounds simple but almost got the whole afternoon. I'm actually suffering from time management problems, that means I STRESS!
Ok, next step, installing Android platform.