使用谷歌地图的应用只显示灰色瓷砖

时间:2013-02-14 16:54:47

标签: android google-maps

我正在尝试制作一个使用谷歌地图的应用程序,我已经尝试了很多东西,但我的手机上的应用程序现在只显示灰色瓷砖。我确信我的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>

1 个答案:

答案 0 :(得分:0)

您缺少互联网连接,或者您的API密钥未获得包名和签名密钥签名组合的授权。检查LogCat是否有与授权相关的警告。