谷歌地图显示在模拟器但不是在装置 [英] Google Map showing on emulator but not on device

查看:134
本文介绍了谷歌地图显示在模拟器但不是在装置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用谷歌地图的应用程序。一切都是模拟器OK和地图作品并显示标记。但真实的设备似乎片段完全不存在,不存在黑屏或异常!

I am developing an app which uses Google Map. Everything is OK on emulator and the map works and shows the markers. But on real device it seems the fragment is not exist at all, there is no black screen or exception!

我了解的调试和发布API密钥,我相信没有什么错在这一部分。应用程序的调试和发行版本上真实的设备测试,但结果都是一样的。

I know about the debug and release API keys and i am sure there is nothing wrong in this part. Both debug and release version of the app tested on real device but results were the same.

以下图片均来自模拟器和真实设备。任何意见将是有益的。

The following images are from the emulator and real device. Any advice would be helpful.


推荐答案

这是有线,你可以尝试更改设备有另一次尝试。马克确保你把XML东西地图片段类似以下内容:

It's wired, you can try to change devices to have a another try. Mark sure you put the map fragment in XML something like following:

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

和初始地图如下:

// Initial Map
        try {

            if (googleMap == null) {
                googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

另外,你可以在我的Github上这里源$ C ​​$ C。它包括一个工作在实际设备上的地图片段

Also, you can the source code on my Github here. It includes a working map fragment on the real device.

这篇关于谷歌地图显示在模拟器但不是在装置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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