Google地图在真实Android设备上空白 - 但适用于模拟器 [英] Google Maps blank on real Android device - but works on Emulator

查看:402
本文介绍了Google地图在真实Android设备上空白 - 但适用于模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



Hola,



我试图让地图起作用,它似乎能够正常工作Nexus 6模拟器,但是当我在Moto G或三星Galaxy上运行它时,地图完全是银行 - 它只在底部包含谷歌徽标。



我已生成一个谷歌地图键,并把它放在我的google_maps_api.xml文件中。我是否必须生成SHA-1证书指纹?
如果是,我该怎么做?

查看答案: https://stackoverflow.com/a/33691443/5387193
我不太明白指示。



这是我的日志:
http://textuploader.com/52xzy



编辑1:
添加到AndroidManifest.xml中的行

 < uses-permission android:name =android.permission.ACCESS_FINE_LOCATION/> 

现在正在使用我的Moto G,但不使用我的三星。我想因为我没有接受敏感信息许可(ACCESS_FINE_LOCATION)。

我正在使用的这个应用程序不需要知道用户的GPS位置,所以我不需要这些敏感信息 - 是否有一种简单的方法删除这个函数和权限?

我认为这个权限是导致这个问题的原因。



编辑2:
我得到了代码:

 <元数据
android:name =com.google。 android.geo.API_KEY
android:value =@ string / google_maps_key/>

在我的AndroidManifest.xml中, @ string / google_maps_key 是我生成的正确密钥。我已经生成了SHA1指纹来获取密钥,我是否需要将指纹放在我的代码中?



我没有生成释放密钥,我认为它只是一个调试键。你认为这可能是问题吗?



我会设置谷歌播放服务,看看它是如何影响它的。



编辑#3:
在Samsung上卸载并重新安装Google Play服务,现在它正在运行。 在你的logcat线似乎是问题:

  02-23 10:02:01.591 5760-5760 / com.companyperth。 companytools E / GMPM:GoogleService初始化失败,状态:10,缺少预期资源:'R.string.google_app_id'用于初始化Google服务。可能的原因是缺少google-services.json或com.google.gms.google服务gradle插件。 

看起来Google Play服务没有正确设置。您需要获取 google-services.json 并将其放入您的项目中。要正确设置Google Play服务,请参阅适用于Android的Google API



如果您使用Google Maps for Android,则需要生成SHA1指纹才能获取Android密钥。请参阅获取API密钥 - 适用于Android的Google地图。但是,如果您使用的是Google Maps JavaScript API(集成到Android中),则您将不需要生成SHA1指纹,因为您将使用服务器密钥。



Hola,

I am trying to get the maps to work, it appears to work fine the the Nexus 6 emulator, however when I run it on a Moto G or a Samsung Galaxy the map is completely bank - it just contains the google logo in the bottom corner.

I have generated a google maps key and put that in my google_maps_api.xml file. Do I have to generate a SHA-1 certificate fingerprint? If yes, how do I do this?

See answer: https://stackoverflow.com/a/33691443/5387193 I don't quite understand the instructions.

Here is my log: http://textuploader.com/52xzy

Edit 1: Added line to AndroidManifest.xml

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

It is now working on my Moto G but not on my Samsung. I think because I haven't accepted the sensitive information permission (ACCESS_FINE_LOCATION).

This app I am working on does not need to know the GPS location of the user, so I don't really need this sensitive information - is there an easy way to remove this function and permission?

I think the permission is causing the problems.

Edit 2: I have got the code:

<meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_maps_key" />

in my AndroidManifest.xml, the @string/google_maps_key is a correct key that I have generated. I have generated a SHA1 fingerprint to get the key, do I need to put the fingerprint in my code somewhere?

I haven't generated a release key, I think it is just a debug key. Do you think this might be the issue?

I will setup google play services and see how that affects it.

Edit #3: Uninstalled and reinstalled Google Play Services on Samsung and now it is working.

解决方案

This line in your logcat seems to be the problems:

02-23 10:02:01.591 5760-5760/com.companyperth.companytools E/GMPM: GoogleService failed to initialize, status: 10, Missing an expected resource: 'R.string.google_app_id' for initializing Google services.  Possible causes are missing google-services.json or com.google.gms.google-services gradle plugin.

It looks like Google Play services is not properly setup. You need to get google-services.json and put it into your project. To set up Google Play Services correctly, see Google APIs for Android.

You need to generate SHA1 fingerprint in order to get the Android key if you are using Google Maps for Android. See Get API key - Google Maps for Android. However, if you are using the Google Maps Javascript API(integrated into Android) you will not need to generate SHA1 fingerprint as you will be using Server Key.

这篇关于Google地图在真实Android设备上空白 - 但适用于模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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