Android:Google地图未显示 [英] Android: Google Maps not displaying

查看:96
本文介绍了Android:Google地图未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试显示Google地图.我可以看到背景(浅灰色背景,小图块,左下角的Google徽标),所以我知道我已经接近了.但是,没有显示实际的地图.在LogCat中,我看到此消息一遍又一遍:

I'm trying to get a google map to display. I can see the background (light gray background, small tiles, Google logo in the lower left), so I know that I'm close. However, there is no actual map displayed. In the LogCat, I see this message repeating over and over:

05-14 13:28:17.926:W/System.err(27458):在 android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher $ DispatcherServer.run(DataRequestDispatcher.java:1702)

05-14 13:28:17.926: W/System.err(27458): at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)

我正在将Google Maps api 2与系留电话一起使用,以运行2.3.4进行测试.

I'm using Google maps api 2 with a tethered phone for testing that is running 2.3.4.

有人知道这可能是什么造成的吗?谢谢!

Anyone know what might be causing this? Thanks!

package com.example.maptest;
import android.os.Bundle;
import com.google.android.maps.MapActivity; 
import com.google.android.maps.MapController; 
import com.google.android.maps.MapView;

public class MyMapActivity extends MapActivity {   

  private MapView mapView;   
  private MapController mapController;

   @Override   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.map_layout);
     mapView = (MapView)findViewById(R.id.map_view);
   }

   @Override   
   protected boolean isRouteDisplayed() {
     return false;   
   }

 }

AndroidManifest.xml

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

    <permission android:name="com.example.maptest.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE"/>
    <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" />

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <uses-library android:required="true" android:name="com.google.android.maps" />

        <activity
            android:name="com.example.maptest.MyMapActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity
             android:name=".MainActivity" >
             </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="xxxxxxxxxxxxxxxxxxxx"/> 

    </application>

</manifest>

推荐答案

此问题通常与用于对清单进行签名的map API密钥有关.看看这篇文章

This problem is usually related to the map API key used to sign manifest. Take a look at this post and this one which describe the same error you are experiencing. In both cases it is because the API key they used was created with the wrong keystore. You need to make sure you use your debug keystore when you create an API key in the Google API console if you are going to be testing from eclipse.

这篇关于Android:Google地图未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆