0

我正在尝试制作一个使用谷歌地图的应用程序,并且我已经尝试了几乎所有东西,但是我手机上的应用程序现在只显示灰色瓷砖。我确信我的 API 密钥是正确的。

这是我的代码

package net.learn2develop.GoogleMaps;

import com.google.android.gms.maps.MapView;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MapsActivity extends MapActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);




}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

}

和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="AIzaSyBZxTMbzMOaFHau-awITz9CtnxZJkYzryg"
    />

</RelativeLayout>

和 android 清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.learn2develop.GoogleMaps"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="8" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
 <permission
      android:name="net.learn2develop.GoogleMaps.permission.MAPS_RECEIVE"
      android:protectionLevel="signature"/>
 <uses-permission android:name="net.learn2develop.GoogleMaps.permission.MAPS_RECEIVE"/>

 <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyBZxTMbzMOaFHau-awITz9CtnxZJkYzryg"/>
    <uses-library android:name="com.google.android.maps"></uses-library>
    <activity
        android:name=".MapsActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>
4

1 回答 1

0

要么您缺少 Internet 连接,要么您的 API 密钥未被授权用于您的包名称和签名密钥签名的组合。检查 LogCat 以获取与授权相关的警告。

于 2013-02-14T17:15:25.897 回答