【发布时间】:2017-06-12 06:06:44
【问题描述】:
我创建了一个新的 Android-Studio 项目,我获得了 API KEY 并且我的 Multidex 已启用,但我的 logcat 中出现此错误:
01-26 16:55:51.989 5606-5750/com.example.maptestdel E/HAL: load: id=gralloc != hmi->id=gralloc
01-26 16:55:52.121 5606-5751/com.example.maptestdel E/b: Authentication failed on the server.
01-26 16:55:52.121 5606-5751/com.example.maptestdel 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.
01-26 16:55:52.125 5606-5751/com.example.maptestdel 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: ABCDEFGHIJKLMNOPQRSTUVWXYZBLABLABLA
Android Application (<cert_fingerprint>;<package_name>): 8B:9C:A2:53:68:BE:3D:3F:4A:53:39:F7:71:83:E6:EB:F4:63:06:6C;com.example.maptestdel
01-26 16:55:53.767 5606-5748/com.example.maptestdel W/DynamiteModule: Local module descriptor class for com.google.android.gms.googlecertificates not found.
如何启用我的 Google Maps Android API v2?
API 密钥是新的,如果我在华为 P8 Lite 上启动应用程序,我会得到一个白屏,左下角有 Google 徽标。
我的 build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.maptestdel"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:multidex:1.0.1'
}
【问题讨论】:
-
你的谷歌控制台说什么?
-
发布问题时请不要发布真实的 API 密钥。那应该是私有的。
标签: java android google-maps android-studio maps