Take the 2-minute tour ×

Hi Im playing around with an android map app tutorial, but I'm getting lots of errors because I dont seem to be importing the com.google.andoid.maps package properly because eclipse is giving me an error for the import and any of its classes. Is there any reason why it shouldnt be working.

import com.google.android.maps.*;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ShowTheMap extends MapActivity {

    private static double lat;
    private static double lon;
    private int latE6;
    private int lonE6;
    private MapController mapControl;
    private GeoPoint gp;
    private MapView mapView;

    private Button overlayButton, accessButton;

    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);  // Suppress title bar for more space

        // Add map controller with zoom controls
        mapView = (MapView) findViewById(R.id.mv);
        mapView.setBuiltInZoomControls(true);   // Set android:clickable=true in main.xml

        int maxZoom = mapView.getMaxZoomLevel();
        int initZoom = maxZoom-2;

        mapControl = mapView.getController();
        // Convert lat/long in degrees into integers in microdegrees
        latE6 =  (int) (lat*1e6);
        lonE6 = (int) (lon*1e6);
        gp = new GeoPoint(latE6, lonE6);

        // Button to control food overlay
        overlayButton = (Button)findViewById(R.id.doOverlay);
        overlayButton.setOnClickListener(new OnClickListener(){      
            public void onClick(View v) {   


        // Button to control access overlay
        accessButton = (Button)findViewById(R.id.doAccess);
        accessButton.setOnClickListener(new OnClickListener(){      
            public void onClick(View v) {   



    // Method to insert latitude and longitude in degrees
    public static void putLatLong(double latitude, double longitude){
        lat = latitude;
        lon =longitude;

    // This sets the s key on the phone to toggle between satellite and map view
    // and the t key to toggle between traffic and no traffic view (traffic view
    // relevant only in urban areas where it is reported).

    public boolean onKeyDown(int keyCode, KeyEvent e){
        if(keyCode == KeyEvent.KEYCODE_S){
            return true;
        } else if(keyCode == KeyEvent.KEYCODE_T){
            mapControl.animateTo(gp);  // To ensure change displays immediately
            return(super.onKeyDown(keyCode, e));

    // Required method since class extends MapActivity
    protected boolean isRouteDisplayed() {
            return false;  // Don't display a route
share|improve this question
Please show the error itself. –  Sirko Feb 18 '13 at 15:23
add comment

2 Answers

up vote 0 down vote accepted

This sounds like it may just be that you are missing the needed packages. Make sure you download the Google APIs in Eclipse with the SDK Manager.

Take a look at this page for some details. https://developers.google.com/android/add-ons/google-apis/installing

A quick snippet from that page mentions this sort of issue

Select the Google APIs Add-On that you want to install and click Install Selected. The add-on is downloaded to your computer and installed in your SDK environment.

When you are ready to develop against the add-on. set your application's properties so that it uses the Google APIs Add-On as the build target. To run the application, create an Android Virtual Device that uses the add-on as it's target. Make sure to select the version (by API level) that is appropriate for your app.

To give your applications access to the Maps library included in the add-on, you need to configure your development and run-time environments properly. The process for doing that is described in the Maps Overview document, which you should read next.

  1. Open the SDK Manager in Eclipse
  2. Find your API version
  3. Check the box Google APIs by Google Inc
  4. Click Install # packages
  5. Restart Eclipse

For example

enter image description here

After that you to reference those new packages so you need to change your Project Build Target

  1. Right click your project
  2. Open Properties
  3. Go to the Android section
  4. Check the box next to Google APIs for the API version you're looking for

For example

enter image description here

share|improve this answer
That did the trick, thanks alot! –  user2083702 Feb 18 '13 at 16:40
add comment

You should be basing your project not off "Android 4.2" but instead off "Google API" with Platform 4.2.

This can be changed in your project properties - Android - Project Build Target.

share|improve this answer
add comment

Your Answer


