谷歌地图APIv2身份验证失败

3
错误信息:
08-15 12:59:17.435: E/Google Maps Android API(14665): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

谷歌控制台: 谷歌控制台 清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cefetmgrdctcc.sgtp"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <permission
        android:name="com.cefetmgrdctcc.sgtp.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>

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

    <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="Hidden key"/>
        <activity
            android:name="com.cefetmgrdctcc.sgtp.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>
    </application>

</manifest>

地图控件的布局方式:
<fragment
    android:id="@+id/googlemap"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.SupportMapFragment" />

我已将Google Play服务导入我的项目,并在Google API控制台服务列表中标记了“Google Maps API v2”、“Google Maps API v3”和“Google Maps Android API v2”,但似乎我的地图片段仍无法验证身份。
地图片段只是屏幕中央的一个空白灰色正方形,有任何想法为什么会发生这种情况?
3个回答

17

嗨,我刚遇到了这个确切的问题。我尝试了文档中提到的一切,但似乎都不起作用。

唯一有效的方法是卸载并重新安装我的应用程序(甚至重启也没有用),因为显然,如果您在配置上犯了一个错误,系统会缓存失败的身份验证,并且即使在修复配置后,您的地图仍将无法工作。

因此,请尝试按照Android上配置谷歌地图API的文档和指南进行操作,但每次更改配置时都要卸载并重新安装。


非常感谢!!!我使用手机设置中的默认应用程序管理器卸载了apk,并重新启动了测试设备。虽然这是一个非常奇怪的错误。 - Eugênio Fonseca
1
这对我也起作用了。使用了错误的google-play-service-lib,应用程序无法使用新库进行身份验证,直到我在设备上卸载该应用程序。在我的情况下不需要重新启动,只需卸载和重新安装即可。 - yc.lin
谢谢你帮我节省了另外三个小时的时间。 - Utku Yıldırım
你应该得到一块饼干,谢谢Jucas。 - OWZY

1
如果您在设备上运行应用程序,并遇到相同的问题,并且没有找到其他解决方案,请执行以下操作: 检查其他依赖于 Google Play 服务的应用程序(例如 Play Store)是否正常工作。如果它们在连接到服务器时出现问题(“无连接,重试”),即使互联网连接可用,上述其中一个点可能是解决方案。

0

我重新生成了API密钥并在Google控制台中进行了更新,现在它可以正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接