我試圖根據Android網站here的教程創建一個MapView應用程序。我已經設置了一切,地圖顯示,但空的瓷磚!Android Google Maps API與debug.keystore不兼容
我使用的API密鑰從位於的debug.keystore生成的「C:\用戶\皮特\ .android」和所有正確的權限都在清單中設置。地圖庫也在清單中,但它仍然不起作用。我已經嘗試創建一個新的調試密鑰庫並將其放置在相同的文件夾中(顯然也會生成一個新的API密鑰),但仍然沒有運氣。
(30/05/2011)編輯:
的Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.stringerapps.testing.gps"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Home"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- import the library com.google.android.maps!!! -->
<uses-library android:name="com.google.android.maps" />
<!-- permissions -->
<uses-permission
android:name="android.permission.INTERNET">
</uses-permission>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION">
</uses-permission>
</application>
</manifest>
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
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:clickable="true"
android:apiKey="api-key-here-omitted"/>
</RelativeLayout>
Home.xml
package com.stringerapps.testing.gps;
import java.util.List;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.LinearLayout;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;
public class Home extends MapActivity {
LinearLayout linearLayout;
MapView mapView;
List<Overlay> mapOverlays;
Drawable drawable;
MyItemizedOverlay itemizedOverlay;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.androidmarker);
itemizedOverlay = new MyItemizedOverlay(drawable);
GeoPoint point = new GeoPoint(19240000, -99120000);
OverlayItem overlayitem = new OverlayItem(point, "", "");
GeoPoint point2 = new GeoPoint(35410000, 139460000);
OverlayItem overlayitem2 = new OverlayItem(point2, "", "");
itemizedOverlay.addOverlay(overlayitem);
itemizedOverlay.addOverlay(overlayitem2);
mapOverlays.add(itemizedOverlay);
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
當您嘗試啓動應用程序時,您遇到了什麼錯誤? – wajiw 2011-05-29 23:07:23
對不起,如果這是愚蠢的,但爲什麼你不能生成自己的API密鑰用於您的Google帳戶? – Alan 2011-05-29 23:07:23
其實,如果我記得,我認爲示例文檔的格式不正確。我會仔細檢查並確保您的清單文件格式正確。 – Alan 2011-05-29 23:10:23