我创建了一个新的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'
}
答案 0 :(得分:0)
How to enable "Google Maps Android API v2" in developers console
请按照上述链接。您可以在Google控制台上创建开发者帐户,创建一个全新的项目,为Android创建密钥并启用所需的地图API。
答案 1 :(得分:0)
由于您没有粘贴整个代码,因此可能会遗漏许多内容
在清单中:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />
在Gradle
顶级构建文件
classpath 'com.google.gms:google-services:3.0.0'
项目级构建文件
apply plugin: 'com.google.gms.google-services'
最后在您的Google Developer Console中,您必须启用Google Maps Android API
试试这个并告诉我这是否适合您