Reputation: 6186
I am working in android. I want to show simple google map in my activity.
This is my main.xml
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="mykey"
/>
This is my Activity:-
package com.quepplin;
import android.app.Activity;
import android.os.Bundle;
import com.google.android.maps.MapView;
public class GooglemapActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mMapView;
mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setBuiltInZoomControls(true);
}
}
I have created google key successfully. But whenever i run my application then it crashes. and following error is displaying in logcat:-
java.lang.RuntimeException: Unable to start activity
android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.maps.MapView
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class com.google.android.maps.MapView
at android.view.LayoutInflater.createView(LayoutInflater.java:513)
Please help me what mistake i have done. I am very new to create google map. I waiting for suggestion.
Thank you in advance.
Upvotes: 0
Views: 215
Reputation: 109237
If I am not wrong then
public class GooglemapActivity extends Activity
should be
public class GooglemapActivity extends MapActivity
and in your manifest file..
<uses-library android:name="com.google.android.maps" />
And your application build platform is Google-api
Upvotes: 3
Reputation: 61
Use MapActivity instead for Activity
public class GooglemapActivity extends MapActivity {
Upvotes: 6