Reputation: 1340
I do the same thing from an example, but Eclipse returns errors. Code is the following:
package hello.google.map;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class MapsActivity 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;
}
}
Here is the errors:
*
Description Resource Path Location Type
MapActivity cannot be resolved to a type HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 7 Java Problem
MapActivity cannot be resolved to a type HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 13 Java Problem
The import com.google cannot be resolved HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 3 Java Problem
The import com.google cannot be resolved HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 4 Java Problem
The method isRouteDisplayed() of type MapsActivity must override a superclass method HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 18 Java Problem
The method onCreate(Bundle) of type MapsActivity must override a superclass method HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 11 Java Problem
The method setContentView(int) is undefined for the type MapsActivity HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 14 Java Problem
The public type MapsActivity must be defined in its own file HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 7 Java Problem*
Why? What I do wrong?
Upvotes: 0
Views: 1527
Reputation: 5673
Your error log says the file name is HelloGoogleMapsActivity.java
but your class name is MapsActivity
. Are you sure you are doing the right thing? Try changing the class name to HelloGoogleMapsActivity
or file name to MapsActivity
. In both case update your manifest.
According to your link the main Activity is MapsActivity
and is defined in the file MapsActivity.java
. So you can cange the file name to MapsActivity.java
to match the example.
Upvotes: 0
Reputation: 3858
use this after your setContentview in on create
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
and put
<application android:icon="@drawable/icon" android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
</app...>
Upvotes: 0
Reputation: 5980
By the looks of it there could be two things you missed. Either you forgot to add the following to your AndroidManifest.xml
<uses-library android:name="com.google.android.maps" />
Or, you are trying to run it on an emulator with a stock Android API instead of the special Google API version. You need this Google API version to use functions such as the map.
If you don't have it, no worries, you can download it in the SDK Manager. Afterwards simply create a new AVD and set the target to the Google API version of your targetted API level.
Upvotes: 1