【发布时间】:2016-01-28 18:33:25
【问题描述】:
我正在 Android Studio 上开发一个 Android 应用,并尝试创建一个 Google Maps Activity。
Android Studio 自动创建了 Activity 和 google_maps_api.xml 文件。然后,我在 Google Developers Console 上创建了 Google Maps Android Key 并将其复制到上述 xml 文件中。我也
当我运行应用程序时它显示以下错误:
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
我尝试将以下行添加到 Manifest
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
还添加了元数据标签
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
这是我的 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'
}
这是 google_maps_aspi.xml 文件
<resources>
<!-- This was my generated key -->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">MY********KEY</string>
</resources>
我还检查了开发者控制台,并且 API 已启用。不是“Google Maps Android API v2”,而是“Google Maps Android API”。
【问题讨论】:
标签: android google-maps android-studio