Android Google地图未显示

Pus*_*tal 0 android google-maps

我在android工作.我想在我的活动中显示简单的谷歌地图.

这是我的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"
 />
Run Code Online (Sandbox Code Playgroud)

这是我的活动: -

 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);

}
Run Code Online (Sandbox Code Playgroud)

}

我已成功创建了Google密钥.但每当我运行我的应用程序然后它崩溃.并在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)
Run Code Online (Sandbox Code Playgroud)

请帮我解决我做错了什么.我是一个非常新的创建谷歌地图.我在等待建议.

先感谢您.

小智 6

使用MapActivity代替Activity

public class GooglemapActivity extends MapActivity {
Run Code Online (Sandbox Code Playgroud)