简体   繁体   English

“无法加载地图。 无法联系Google服务器。“

[英]“Failed to load map. Could not contact Google servers.”

I've looked at just about every question on here regarding this error and still haven't been able to track it down. 我已经看过这里关于这个错误的每一个问题,但仍然无法追踪它。

Here's my manifest: 这是我的清单:

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

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

    <permission
        android:name="com.example.cs2110_final.TheHunt.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.cs2110_final.MainActivity"
            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="com.example.cs2110_final.TheHunt"
            android:label="@string/title_activity_the_hunt" >
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="(API key edited out)" />
    </application>

</manifest>

Here's my Activity code: 这是我的活动代码:

mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

And here's the XML reference to the Map: 这是对Map的XML引用:

 <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true" />

I've gone through the entire API process three times now and no luck. 我现在已经完成了三次整个API过程而没有运气。 Every permission that needs to be put in the manifest has been, as far as I can tell (even the sneaky GPS_Services one). 据我所知,每个需要放入清单的权限(即使是偷偷摸摸的GPS_Services)也是如此。 Any ideas? 有任何想法吗? Thanks in advance for any help! 在此先感谢您的帮助!

Edit: here's the LogCat output. 编辑:这是LogCat输出。 It's this, followed by many repetitions of "Failed to load map..." 就是这样,接下来又重复了几次“无法加载地图......”

04-19 13:59:03.108: D/dalvikvm(26070): GC_CONCURRENT freed 252K, 6% free 7534K/7940K, paused 4ms+7ms, total 29ms
04-19 13:59:03.138: D/libEGL(26070): loaded /system/lib/egl/libEGL_tegra.so
04-19 13:59:03.148: D/libEGL(26070): loaded /system/lib/egl/libGLESv1_CM_tegra.so
04-19 13:59:03.168: D/libEGL(26070): loaded /system/lib/egl/libGLESv2_tegra.so
04-19 13:59:03.198: D/OpenGLRenderer(26070): Enabling debug mode 0
04-19 13:59:05.968: D/dalvikvm(26070): GC_CONCURRENT freed 301K, 6% free 7654K/8108K, paused 3ms+3ms, total 21ms
04-19 13:59:06.048: D/dalvikvm(26070): GC_CONCURRENT freed 216K, 5% free 7877K/8248K, paused 3ms+2ms, total 29ms
04-19 13:59:06.128: D/dalvikvm(26070): GC_CONCURRENT freed 309K, 6% free 8079K/8540K, paused 3ms+3ms, total 26ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 5ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 5ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 6ms
04-19 13:59:06.128: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 6ms
04-19 13:59:06.198: D/dalvikvm(26070): GC_CONCURRENT freed 250K, 5% free 8330K/8736K, paused 2ms+2ms, total 24ms
04-19 13:59:06.198: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 8ms
04-19 13:59:06.258: D/dalvikvm(26070): GC_CONCURRENT freed 317K, 6% free 8527K/8996K, paused 2ms+3ms, total 25ms
04-19 13:59:06.258: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 10ms
04-19 13:59:06.258: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 10ms
04-19 13:59:06.378: D/dalvikvm(26070): GC_CONCURRENT freed 271K, 5% free 8689K/9128K, paused 2ms+6ms, total 31ms
04-19 13:59:06.378: D/dalvikvm(26070): WAIT_FOR_CONCURRENT_GC blocked 13ms
04-19 13:59:06.398: D/dalvikvm(26070): GC_FOR_ALLOC freed 283K, 8% free 8558K/9260K, paused 23ms, total 23ms
04-19 13:59:06.438: D/dalvikvm(26070): GC_FOR_ALLOC freed 303K, 8% free 8566K/9260K, paused 26ms, total 26ms
04-19 13:59:06.478: D/dalvikvm(26070): GC_FOR_ALLOC freed 325K, 8% free 8567K/9260K, paused 25ms, total 25ms
04-19 13:59:06.518: D/dalvikvm(26070): GC_FOR_ALLOC freed 304K, 8% free 8568K/9260K, paused 25ms, total 25ms
04-19 13:59:06.538: E/Google Maps Android API(26070): Failed to load map.  Could not contact Google servers.
04-19 13:59:06.598: D/dalvikvm(26070): GC_CONCURRENT freed 381K, 8% free 8579K/9260K, paused 6ms+4ms, total 51ms

Did you check the correct services are enabled? 您是否检查了正确的服务是否已启用? Once I had a similar problem, and my issue was I accidentally enabled Google Maps API v2 in place of Google Maps Android API v2 . 一旦我遇到类似的问题,我的问题就是我不小心启用了Google Maps API v2来代替Google Maps Android API v2

Please check that you are enabled the correct Google map API service for android, which is Google Maps Android API v2 . 请检查您是否为Android启用了正确的Google地图API服务,即Google Maps Android API v2

As it looks your problem is those two permissions: 看起来你的问题是这两个权限:

 <permission
    android:name="com.example.cs2110_final.TheHunt.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.cs2110_final.permission.MAPS_RECEIVE" />

Which should be identical from the point of your package name, meaning if in one you wrote: 从您的包名称的角度来看,这应该是相同的,这意味着如果你写了一个:

com.example.cs2110_final 

which is your package name, then the second one should be the same, like that: 这是你的包名,那么第二个应该是相同的,就像那样:

  <permission
    android:name="com.example.cs2110_final.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.cs2110_final.permission.MAPS_RECEIVE" />

In addition make sure you are following all the steps of producing your API key, you can follow this guide I wrote on this topic: 此外,请确保您遵循生成API密钥的所有步骤,您可以按照我在此主题上撰写的本指南:

Google Maps API V2 Key Google Maps API V2键

Another problem I see in your code is the fact that you min target API version 8 ( android:minSdkVersion="8" ), So you should use the SupportMapFragment and FragmentActivity and not MapFragment and a simple Activity as you are doing right now. 我在你的代码中看到的另一个问题是你最小的目标API版本8( android:minSdkVersion="8" ),所以你应该使用SupportMapFragmentFragmentActivity而不是MapFragment和一个简单的Activity正如你现在所做的那样。 But as far as my knowledge goes this doesn't have to do anything with the problem you are having right now. 但据我所知,这对你现在遇到的问题没有任何意义。

Still you will have to change it, you can follow this guide I wrote to do that: 你仍然需要改变它,你可以按照我写的指南来做到这一点:

Google Maps API V2 Google Maps API V2

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 修复无法加载地图。 无法联系Google服务器。 - Fix the Failed to load map. Could not contact Google servers. 授权失败。 无法加载地图。 无法联系Google服务器。 (适用于Android的Google Map) - Authorization failed. Failed to load map. Could not contact Google servers. (Google Map for Android) Google Maps android中的错误“android无法加载地图。 无法联系Google服务器。“ - Error in Google Maps android “android Failed to load map. Could not contact Google servers.” 无法加载地图。 无法联系Google服务器 - Failed to load map. Could not contact Google servers 无法加载地图。 无法联系Google服务器 - Failed to load map. Could not contact Google servers Android地图:无法加载地图。 无法联系Google服务器 - Android Maps: Failed to load map. Could not contact Google servers Google Maps API V2&#39;无法加载地图。 无法联系Google服务器 - Google Maps API V2 'Failed to Load Map. Could not contact Google Servers' Android版Google地图。 无法加载地图。 无法联系Google服务器 - Google Maps for Android. Failed to load map. Could not contact Google servers Google Maps Android API v2:无法加载地图。 无法与Google服务器联系 - Google Maps Android API v2: Failed to Load Map. Could not contact Google Servers “无法加载地图。 与Google服务器联系时出错。” 1台电脑出现问题 - “Failed to load map. Error contacting Google servers.” problems with 1 pc
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM