谷歌地图未显示/空白 [英] Google Maps not shown / blank

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

问题描述

我找到了关于此的不同主题,但都没有让我在我的活动中使用地图.我遵循了谷歌提供的关于使用谷歌播放服务地图的指南:

I've found different topic about this, but neither got me the maps working in my activity. I've followed the guide provided by google about using maps from google play service:

  1. 我已下载 Google Play 服务并将其添加到我的库中
  2. 我创建了一个基于服务 > 地图活动的新活动模板
  3. 我已按照 google_maps_api.xml 中的说明进行操作获取api密钥
  4. 在我的设备上构建并运行应用程序
  5. 意识到我遗漏了一些我从清单中的其他线程建议添加的权限

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="net.labinfo.hotels.core" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="net.labinfo.hotels.core.permission.MAPS_RECEIVE"/>
    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <uses-permission android:name="net.labinfo.hotels.core.permission.C2D_MESSAGE" />
    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <application
        android:allowBackup="true"
        android:largeHeap="true"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.google.android.gms.analytics.globalConfigResource"
            android:resource="@xml/global_tracker" />
      
      .....
      
        </activity>

        <activity
            android:name=".components.activities.avis.AvisMappaActivity"
            android:label="@string/title_activity_avis_mappa" >
        </activity>

        <uses-library android:name="com.google.android.maps"/>
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/google_maps_key" />

    </application>

</manifest>

结果仍然是活动在角落仅显示 google 徽标,并且没有来自 logcat 的错误或通知的迹象.我错过了什么吗?我看到在 google 控制台生成 api 密钥期间它向我显示了一个 SHA 密钥,但我从未使用过它.

Still the result is the activity showing only the google logo in the corner and no sign of errors or notifications from logcat. Am I missing something? I saw that during the google console generation of the api key it showed to me a SHA key, but I've never used it.

希望有人能帮我解决这个问题

Hope somebody can help me out about this

推荐答案

我已经解决了.正如你们所有人所说,它是 API 密钥,特别是与该密钥相关的权限.

I've solved it. As all of you suggested it was the API key, in particular permissions related to that key.

我的问题是包名,因为我使用了一个具有不同模块的应用程序,发送到服务器的包名与用于自动创建密钥的包名不同.所以我已经解决了使用相同的 SHA1 密钥向权限添加另一个包名称的问题.

My problem was the package name, since I used an app with different module, the package name sent to the server was different than the one used to create the key automatically. So I've fixed the problem adding to permission another package name with the same SHA1 key.

对于所有未来的读者,我希望您注意在我从 SupportMapFragment 切换到 MapFragment 之前我没有显示任何错误,因此我建议这样做以进行调试.

感谢任何人的帮助,干杯.

Thanks to anyone helping, cheers.

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

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