Android How To Make Google Maps Application

NOTE: DEPRECATED. You should use Google Maps Android API V2
Sometimes in our applications we have to add new features like Maps. So in today’s tutorial I will show you how to create a map for your application and what you need in order to create it.
Firts of all you have to run the application with Google APIs add-on! To do this, go to emulator settings and change the platform to GoogleApis.(example: if you have Android 2.1 Platform you must change it to Google APIs). But if you don’t have it you must download this add-on as is described here:
http://code.google.com/android/add-ons/google-apis/installing.html
Step 1: If you test your application with the emulator you must find debug.keystore. To find it, press the Windows start button and make a search for debug.keystore and press right click on it and select Open File Location. If you can’t find it in this way you should know that in general the debug.keystore is localized in C:\Users\name_of_your_PC\.android. After you find it, make a folder in “C:\”, called “Android”, so you have something like this: “C:\Android”. In this folder copy the debug.keystore

Step 2: Now open cmd and change the default path to where your Java is installed. In my case it is installed in C:\Program Files\Java\jre6\bin. So, to get to this path you have to use the command “cd..” until you have only “C:\”. After this, type “cd Program Files”-press enter button – “cd Java” – press enter button – “cd jre6” – press enter button – “cd bin”- press enter button. Of course if your Java files are installed somewhere else you have to change the directory to where they are. You have to get to Java\bin because here is the keytool.

Step 3: Enter the following in the cmd code and press enter:

keytool.exe -list -alias androiddebugkey -keystore “C:\android\debug.keystore” -storepass android -keypass android

Now you have obtained your certificate fingerprint.

Step 4: Copy the certificate fingerprint obtained and navigate your web browser to http://code.google.com/android/maps-api-signup.html. Here you have to introduce your certificate and google will generate an api key which you will have to use in your android application.

 

Step 5: Now you have to go to your android project and modify the AndroidManifest.xml file by adding the  element together with the Internet permission , like in the picture below:

As you can see here you put the apikey obtained. So the row with the key you will have to change with your key.

Step 6: In your main.xml layout you have to modify the LinearLayout to RelativeLayout and put the code like in the below example:

NOTE: If you are not allowed to put the 

com.google.android.maps.MapView

in the RelativeLayout then you should delete the RelativeLayout and let only the maps code like is describe here at step 5.
Step 7: Now you must modify your activity class. To do so, extend your class to MapActivity instead of Activity.

public class Maps 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() {
    return false; 
 }
}

 

And now that you learned how to show a map from your application you should also see the result:

I hope this tutorial helped you.
Scroll to Top