简体   繁体   English

Google Maps Android无法验证

[英]Google Maps Android not Authenticating

I'm developing an Android app on Android Studio and tried to create a Google Maps Activity. 我正在Android Studio上开发Android应用程序,并尝试创建Google Maps Activity。

Android Studio Automatically created the Activity and the google_maps_api.xml file. Android Studio自动创建了Activity和google_maps_api.xml文件。 Then, I created the Google Maps Android Key on Google Developers Console and copied it into the mentioned xml file. 然后,我在Google Developers Console上创建了Google Maps Android Key,并将其复制到上述xml文件中。 I also 我也

When I run the application It shows the following error: 当我运行应用程序时,它显示以下错误:

01-28 13:16:21.279 5689-5863/com.comunity.dxmobile.tooltester E/b: Authentication failed on the server.
01-28 13:16:21.279 5689-5863/com.comunity.dxmobile.tooltester E/Google Maps Android API: Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-28 13:16:21.284 5689-5863/com.comunity.dxmobile.tooltester 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: AIza****vlmk
                                                                                            Android Application (<cert_fingerprint>;<package_name>): 57:29:****:77:1A:71;com.comunity.dxmobile.tooltester

I tried to add the following line to the Manifest 我试图将以下行添加到清单中

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>

The metadata tag was also added 元数据标签也已添加

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

This is my gradle file 这是我的gradle文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "com.comunity.dxmobile.tooltester"
        minSdkVersion 14
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:percent:23.0.1'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.android.gms:play-services:8.4.0'
}

This is the google_maps_aspi.xml file 这是google_maps_aspi.xml文件

<resources>
<!-- This was my generated key -->
    <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">MY********KEY</string>
</resources>

I also checked in the developer console and the api is enable. 我还检查了开发者控制台,并启用了api。 Not the "Google Maps Android API v2" but the "Google Maps Android API". 不是“ Google Maps Android API v2”,而是“ Google Maps Android API”。

Make sure you added the following to your AndroidManifest.xml, at the <application> tag level: 确保在<application>标签级别将以下内容添加到AndroidManifest.xml中:

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

You should also include the generated key from the Google Developer Console in a new resource file keys.xml, like this: 您还应该在新的资源文件keys.xml中包含从Google Developer Console生成的密钥,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">INSERT YOUR GENERATED KEY</string>
</resources>

did u add the meta data related to maps in manifest like below 您是否在清单中添加了与地图相关的元数据,如下所示

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

In your console log: exception says Ensure that the "Google Maps Android API v2" is enabled. 在控制台日志中:例外,请确保已启用“ Google Maps Android API v2”。

Please check your google developer account, you need enable the Map API. 请检查您的Google开发人员帐户,您需要启用Map API。

Login with your account and check for API is enable or disable. 使用您的帐户登录并检查API是否已启用。 https://console.developers.google.com/apis/api/maps_android_backend/overview?project https://console.developers.google.com/apis/api/maps_android_backend/overview?project

我遇到了同样的问题,请转至Google 网站 ,找到“显示调试证书指纹”部分,然后按照说明进行操作,就可以了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM