Google地图不显示/空白 [英] Google Maps not shown / blank

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

问题描述

我发现了这个不同的话题,但都没有让我看到在我的活动中工作的地图。
我遵循了google提供的有关使用Google Play服务中的地图的指南:


  1. 我已下载并添加到我的图书馆Google Play服务

  2. 我已经根据服务>地图活动
    模板创建了一项新活动

  3. google_maps_api.xml到
    的指令获取api键

  4. 在我的设备上构建并运行应用程序
  5. 实现了我错过了一些我已经从清单中的其他线程中添加权限

    $ b

    <?xml version =1.0encoding =utf-8?>< manifest xmlns:android =http://schemas.android.com/apk/res/androidpackage =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需要一个Google帐户。 - > < uses-permission android:name =android.permission.GET_ACCOUNTS/> < uses-permission android:name =net.labinfo.hotels.core.permission.C2D_MESSAGE/> <! - 收到消息时使处理器保持休眠状态。 - > < uses-permission android:name =android.permission.WAKE_LOCK/> < uses-permission android:name =com.google.android.providers.gsf.permission.READ_GSERVICES/> < application android:allowBackup =trueandroid:largeHeap =trueandroid:theme =@ style / AppTheme> < meta-data android:name =com.google.android.gms.analytics.globalConfigResourceandroid:resource =@ xml / global_tracker/> .....< / activity> < activity android:name =。components.activities.avis.AvisMappaActivityandroid:label =@ string / title_activity_avis_mappa> < /活性GT; < uses-library android:name =com.google.android.maps/> < meta-data android:name =com.google.android.maps.v2.API_KEYandroid:value =@ string / google_maps_key/> < / application>< / manifest>

    是只显示角落里的谷歌徽标的活动,没有logcat错误或通知的迹象。
    我错过了什么吗?我看到在api键的谷歌控制台生成过程中,它向我展示了一个SHA键,但我从来没有使用它。



    希望有人能帮助我这

    解决方案

    我解决了它。正如你们所有人都建议这是API密钥,特别是与该密钥相关的许可。



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



    对于所有未来的读者,我希望您注意到我拥有没有错误显示,直到我从SupportMapFragment切换到MapFragment,所以我建议这样做进行调试。



    感谢任何人的帮助,欢呼。


    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. I've download and added to my libraries google play services
    2. I've created a new activity based on the Service > Map Activity template
    3. I've followed the instructions in google_maps_api.xml to get the api key
    4. Built and run the application on my device
    5. Realized I missed something I've added permissions suggested from other threads in the manifest

    <?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>

    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

    解决方案

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

    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.

    For all future readers, I want you to note that I had no error shown until I switched from SupportMapFragment to MapFragment, so I suggest to do so for debugging.

    Thanks to anyone helping, cheers.

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

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