Eclipse ADT & Google APIs: Fixing “MapActivity cannot be resolved to a type”


After using the SDK Manager to download and install the Google APIs Add-On (see http://code.google.com/intl/de-DE/android/add-ons/google-apis/installing.html) one can start to develop Android applications that uses the Google services like Google Maps.

After changing the parent class of your activity to MapActivity one has to select one of the Google APIs as “Android Built Target” (Right click on project > Properties > Android). Otherwise the class com.google.android.maps.MapActivity cannot be resolved and you will get the error:

MapActivity cannot be resolved to a type

The basic MapActivity class will look like this:

package com.package;

import com.google.android.maps.MapActivity;
import android.os.Bundle;

public class MyMapActivity extends MapActivity {
	
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    [...]
    setContentView(R.layout.main);
  }
    
  @Override
  protected boolean isRouteDisplayed() {
    return false;
  }
    
}
,

Leave a Reply

Your email address will not be published. Required fields are marked *