Google 地图 Android API:授权失败。确保 "Google Maps Android API v2" 已启用。确保以下 Android 项存在
Google Maps Android API: Authorization failure. Ensure that the "Google Maps Android API v2" is enabled. Ensure that the following Android Key exists
-
google-maps
-
google-maps-api-3
-
google-play-services
-
google-maps-android-api-2
-
google-maps-android-api-1
我收到这个错误:
E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: [The key...]
Android Application (<cert_fingerprint>;<package_name>):
地图没有正常工作,这是我看到的:
在我的 app/build.gradle
中,我有这个:
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-awareness:16.0.0'
implementation 'com.google.android.gms:play-services-cast:16.2.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
play-services-location
是 Google 地图所需要的,对吗?我正在查看 https://developers.google.com/android/guides/setup 的列表,我认为 Google Location and Activity Recognition - com.google.android.gms:play-services-location:16.0.0
是我需要的 Google 地图。这是正确的吗?
更新 1: 我已经为 Android 启用了 Maps SDK:
错误显示:Ensure that the "Google Maps Android API v2" is enabled.
。它指的是我在 UPDATE 1 的屏幕截图中显示的 Maps SDK for Android
吗?
更新 2: 我启用了 Maps SDK for Android
:
当我单击 MANAGE
按钮时,我可以转到配置我在 UPDATE 1.
中显示的凭据的部分
更新 3: 我看到地图在模拟器的所有 Android 版本上都正确显示。但在物理设备上,地图永远不会出现。我看到了 Google 徽标和红色气球,但现在当我在实体手机上 运行 应用程序时看到了地图。只有在模拟器上一切正常。有什么想法吗?
更新 4: 在 查看我的解决方案。
嘿,我今天遇到了同样的问题!我很容易地解决了这个问题,因为首先您必须去 https://console.developers.google.com 并启用 android SDK 映射,然后创建 api 密钥, return 在 xamarin 中转到您的清单并添加 google 映射 api 键
这是文档
(我打字这么快因为我现在在手机上抱歉)
我遵循了本教程并且能够修复它:https://www.youtube.com/watch?v=sJBlQv6IptQ. The video makes references to this tutorial: http://ramsandroid4all.blogspot.com/2016/01/google-maps-android-example-in-android.html。
就我而言,我所做的是在 https://console.developers.google.com/ 创建一个新项目。我将 Android apps
用于 Application restrictions
:
对于 Restrict usage to your Android apps
部分,我必须提供一个 Package name
和一个 SHA-1 certificate fingerprint
。 Package name
在我的 app/build.gradle
中,特别是这里:
applicationId "[my package name]"
SHA-1 certificate fingerprint
我从 Android Studio 找到它 运行 signingReport
:
结果包括如下内容:
Alias: AndroidDebugKey
MD5: [The value]
SHA1: [The value]
SHA-256: [The value]
Valid until: Wednesday, May 5, 2049
----------
BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
16:31:44: Task execution finished 'signingReport'.
现在地图在我的 Android 应用程序中可以正常工作了:
更新 1: 令我惊讶的是,地图仅在 Android Studio 模拟器上正常工作,但在真正的 Android 物理设备上却无法正常工作。解决方案是我在 .
上发布的内容
按照以下 link 生成 google api 密钥:-
https://developers.google.com/maps/documentation/android-sdk/map-with-marker
Android代码参考Link:-
将项目移至新计算机时出现完全相同的症状。我的解决方案是根据错误消息生成一个新密钥。 google_maps_api.xml 文件在注释中有一个 URL 来生成密钥,但这是一个静态的东西,所以在将项目移动到新计算机后,我重写了 URL 以匹配错误消息的版本.
生成密钥,将其放入 XML 文件中,效果很好。
对于那些还没有弄清楚的人,请再次查看错误消息下方的日志记录。密切注意日志中打印出的 certifcate_fingerprint 和 package_name 。仔细比较这些与您的 Google 开发控制台中指定的那些。
在将近整整一年的闲置之后,我再次拿起了一个旧的爱好项目。我可能在某处更改了触发证书指纹更改的内容,反之亦然。
希望对您有所帮助!
时间改变了配置步骤。这是新的。
设置你的项目https://console.cloud.google.com/projectselector2/home/dashboard
启用 Google 地图 API。转到 https://console.cloud.google.com/apis/library?filter=category:maps&_ga=2.192684329.2027491681.1618180744-3962552.1609436892 选择要启用的 API
转到您项目的 API 凭据 https://console.cloud.google.com/project/_/apiui/credential
在凭据页面上,单击创建凭据 > API 密钥。
API 密钥创建对话框显示您新创建的 API 密钥
单击“关闭”。
在 Android Studio 中,打开您的应用级 build.gradle 文件并将以下代码添加到插件元素。 id 'com.google.secrets_gradle_plugin' version '0.5'
保存文件并将您的项目与 Gradle
同步
打开values\google_maps_api.xml
,将YOUR_API_KEY
替换为第4点得到的API
检查您的 AndroidManifest.xml MAPS_API_KEY
已替换为您的实际密钥
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />
- 插入你的 AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
- 转到 APIs & Services > Credentials 页面 https://console.cloud.google.com/project/_/apiui/credential
- Select 您要对其设置限制的 API 键。 API键属性页面出现
- 在密钥限制下 --> Select Android 应用程序。
单击 + 添加包名称和指纹。
输入您的包名称和 SHA-1 证书指纹单击限制密钥。
Select Android 的 Maps SDK 来自 Select APIs dropdow
- 要完成更改,请单击“保存”。
就我而言,我做的一切都是对的。但仍然出现错误,事实证明更改清单文件中的属性“android:name”解决了问题。
改变
android:name="com.google.android.maps.API_KEY"
至
android:name="com.google.android.maps.v2.API_KEY"
google-maps
google-maps-api-3
google-play-services
google-maps-android-api-2
google-maps-android-api-1
我收到这个错误:
E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: [The key...]
Android Application (<cert_fingerprint>;<package_name>):
地图没有正常工作,这是我看到的:
在我的 app/build.gradle
中,我有这个:
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.8'
implementation 'com.google.android.gms:play-services-awareness:16.0.0'
implementation 'com.google.android.gms:play-services-cast:16.2.0'
implementation 'com.google.android.gms:play-services-gcm:16.1.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
play-services-location
是 Google 地图所需要的,对吗?我正在查看 https://developers.google.com/android/guides/setup 的列表,我认为 Google Location and Activity Recognition - com.google.android.gms:play-services-location:16.0.0
是我需要的 Google 地图。这是正确的吗?
更新 1: 我已经为 Android 启用了 Maps SDK:
错误显示:Ensure that the "Google Maps Android API v2" is enabled.
。它指的是我在 UPDATE 1 的屏幕截图中显示的 Maps SDK for Android
吗?
更新 2: 我启用了 Maps SDK for Android
:
当我单击 MANAGE
按钮时,我可以转到配置我在 UPDATE 1.
更新 3: 我看到地图在模拟器的所有 Android 版本上都正确显示。但在物理设备上,地图永远不会出现。我看到了 Google 徽标和红色气球,但现在当我在实体手机上 运行 应用程序时看到了地图。只有在模拟器上一切正常。有什么想法吗?
更新 4: 在
嘿,我今天遇到了同样的问题!我很容易地解决了这个问题,因为首先您必须去 https://console.developers.google.com 并启用 android SDK 映射,然后创建 api 密钥, return 在 xamarin 中转到您的清单并添加 google 映射 api 键
这是文档 (我打字这么快因为我现在在手机上抱歉)
我遵循了本教程并且能够修复它:https://www.youtube.com/watch?v=sJBlQv6IptQ. The video makes references to this tutorial: http://ramsandroid4all.blogspot.com/2016/01/google-maps-android-example-in-android.html。
就我而言,我所做的是在 https://console.developers.google.com/ 创建一个新项目。我将 Android apps
用于 Application restrictions
:
对于 Restrict usage to your Android apps
部分,我必须提供一个 Package name
和一个 SHA-1 certificate fingerprint
。 Package name
在我的 app/build.gradle
中,特别是这里:
applicationId "[my package name]"
SHA-1 certificate fingerprint
我从 Android Studio 找到它 运行 signingReport
:
结果包括如下内容:
Alias: AndroidDebugKey
MD5: [The value]
SHA1: [The value]
SHA-256: [The value]
Valid until: Wednesday, May 5, 2049
----------
BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
16:31:44: Task execution finished 'signingReport'.
现在地图在我的 Android 应用程序中可以正常工作了:
更新 1: 令我惊讶的是,地图仅在 Android Studio 模拟器上正常工作,但在真正的 Android 物理设备上却无法正常工作。解决方案是我在
按照以下 link 生成 google api 密钥:- https://developers.google.com/maps/documentation/android-sdk/map-with-marker
Android代码参考Link:-
将项目移至新计算机时出现完全相同的症状。我的解决方案是根据错误消息生成一个新密钥。 google_maps_api.xml 文件在注释中有一个 URL 来生成密钥,但这是一个静态的东西,所以在将项目移动到新计算机后,我重写了 URL 以匹配错误消息的版本.
生成密钥,将其放入 XML 文件中,效果很好。
对于那些还没有弄清楚的人,请再次查看错误消息下方的日志记录。密切注意日志中打印出的 certifcate_fingerprint 和 package_name 。仔细比较这些与您的 Google 开发控制台中指定的那些。
在将近整整一年的闲置之后,我再次拿起了一个旧的爱好项目。我可能在某处更改了触发证书指纹更改的内容,反之亦然。
希望对您有所帮助!
时间改变了配置步骤。这是新的。
设置你的项目https://console.cloud.google.com/projectselector2/home/dashboard
启用 Google 地图 API。转到 https://console.cloud.google.com/apis/library?filter=category:maps&_ga=2.192684329.2027491681.1618180744-3962552.1609436892 选择要启用的 API
转到您项目的 API 凭据 https://console.cloud.google.com/project/_/apiui/credential
在凭据页面上,单击创建凭据 > API 密钥。 API 密钥创建对话框显示您新创建的 API 密钥
单击“关闭”。
在 Android Studio 中,打开您的应用级 build.gradle 文件并将以下代码添加到插件元素。
id 'com.google.secrets_gradle_plugin' version '0.5'
保存文件并将您的项目与 Gradle
同步打开
values\google_maps_api.xml
,将YOUR_API_KEY
替换为第4点得到的API检查您的 AndroidManifest.xml
MAPS_API_KEY
已替换为您的实际密钥
android:name="com.google.android.geo.API_KEY"
android:value="${MAPS_API_KEY}" />
- 插入你的 AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
- 转到 APIs & Services > Credentials 页面 https://console.cloud.google.com/project/_/apiui/credential
- Select 您要对其设置限制的 API 键。 API键属性页面出现
- 在密钥限制下 --> Select Android 应用程序。 单击 + 添加包名称和指纹。 输入您的包名称和 SHA-1 证书指纹单击限制密钥。 Select Android 的 Maps SDK 来自 Select APIs dropdow
- 要完成更改,请单击“保存”。
就我而言,我做的一切都是对的。但仍然出现错误,事实证明更改清单文件中的属性“android:name”解决了问题。
改变
android:name="com.google.android.maps.API_KEY"
至
android:name="com.google.android.maps.v2.API_KEY"