我正在我的应用程序上实现谷歌地图。
我已经获得了我的API密钥等,目前正在遵循一系列的教程。我需要扩展MapActivity超类,但目前还不能这样做。
我已经在清单中实现了地图库,并在XML布局中插入了API密钥。
但仍然收到“无法将MapActivity解析为类型”错误。以下是我的清单:
<?xml version="1.0" encoding="utf-8"?>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".MainMap"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>这是我的XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="AIzaSyCJSfjl_7lU7-HKV3yIf5nnMODl6qiG2_g"
/>
</RelativeLayout>还有我的班级:
package com.example.map;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainMap extends MapActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.maplayout);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.maplayout, menu);
return true;
}
}发布于 2013-02-16 22:10:05
确保您的构建目标(例如,Eclipse中的Project > Properties > Android )是针对Android SDK的"Google API“版本。
发布于 2013-02-16 22:12:13
试试这个:
使用项目属性选择项目构建目标是Google API
https://stackoverflow.com/questions/14911153
复制相似问题