今天下载了百度地图的demo,然后按照要求申请了key,但总是报这个错误
Authentication Error
=============================================
—————– 鉴权错误信息 ————
sha1;package:5D:87:28:93:2C:DC:12:D0:7C:E2:C1:EF:14:CE:A3:77:E5:CB:9A:0A;baidumapsdk.demo
key:B81INSAGv6MD23X6VhFma8GzPlLGyGxm
errorcode: 230 uid: -1 appid -1 msg: APP Scode码校验失败
请仔细核查 SHA1、package与key申请信息是否对应,key是否删除,平台是否匹配
我以为是我的key申请有问题,从新申请了一遍,还是报错,看了下书写格式,是不是有空格,结果如下
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="B81INSAGv6MD23X6VhFma8GzPlLGyGxm" />
也没空格啊;
没办法打开gradle文件看下,
/*
* Copyright (C) 2015 Baidu, Inc. All Rights Reserved.
*/
apply plugin: 'com.android.application'
repositories {
flatDir {
dir 'libs'
}
}
android {
compileSdkVersion 22
buildToolsVersion "23.0.2"
signingConfigs {
// your debug keystore
debug{
storeFile file("debug.keystore")
}
}
sourceSets {
main {
jniLibs.srcDir 'libs'
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
defaultConfig {
applicationId "baidumapsdk.demo"
minSdkVersion 9
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
看这里
这里提示我们用自己的keystore,在默认的项目用的是是src文件夹下的keystore(上图红色框框),但是我们申请秘钥生成key的时候用的是自己的keystore(在.android目录下),所以两者发生冲突。
解决办法如下:注释掉就可以了