Google Maps API v2不支持发行密钥 [英] Google Maps API v2 does not work with release key

查看:105
本文介绍了Google Maps API v2不支持发行密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了大约一个星期来解决这个问题。我有谷歌地图工作完美罚款在调试,但无论我做什么时,我打包apk我得到这个错误下面

  05-21 21:00:21.338 31534-31613 /? E / Google Maps Android API:无法加载地图。联系Google服务器时出错。这可能是一个身份验证问题(但可能是由于网络错误)。 

我运行了以下命令:

 keytool -list -v -keystore〜/ Documents / keys / phillybikeshare.jks -aliaspbs

在两个不同的密钥库中,采用了看起来像

 的F9:DB: 33:A2:05:02:80:5A:21:9A:19:E6:8A:E4:C4:XX:XX:XX:XX:XX 

,并在Google开发者控制台中为SHA1制作了api密钥。我甚至仔细检查过,以确保在 main / res / values / google_maps_api.xml debug / res / values / google_maps_api中都有一个变量。 xml 仍然没有。



AndroidManifest.xml

 <?xml version =1.0encoding =utf-8?> 
< manifest xmlns:android =http://schemas.android.com/apk/res/android
package =com.peterchappy.phillybikeshare>

<使用权限android:name =android.permission.INTERNET/>
< uses-permission android:name =android.permission.ACCESS_NETWORK_STATE/>
< uses-permission android:name =android.permission.WRITE_EXTERNAL_STORAGE/>
<使用权限android:name =android.permission.ACCESS_WIFI_STATE/>
<使用权限android:name =com.google.android.providers.gsf.permission.READ_GSERVICES/>
< uses-permission android:name =android.permission.ACCESS_COARSE_LOCATION/>
< uses-permission android:name =android.permission.ACCESS_FINE_LOCATION/>
< permission
android:name =com.peterchappy.phillybikeshare.MAPS_RECEIVE
android:protectionLevel =signature/>
<使用权限android:name =com.peterchappy.phillybikeshare.MAPS_RECEIVE/>

< uses-feature
android:glEsVersion =0x00020000
android:required =true>
< /使用特征>

< application
android:allowBackup =true
android:icon =@ mipmap / ic_launcher
android:label =@ string / app_name
android:theme =@ style / AppTheme>
< 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 =@ string / google_maps_key/>

< activity
android:name =。activities.MainActivity
android:label =@ string / title_activity_main>
< intent-filter>

< category android:name =android.intent.category.LAUNCHER/>
< / intent-filter>
< / activity>

< service
android:name =。services.AlarmService
android:exported =false>
< / service>
< / application>



build.gradle

  apply plugin:'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion21.1.2

defaultConfig {
applicationIdcom.peterchappy.phillybikeshare
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName1.0
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro '
}
}
}

依赖关系{
编译fileTree(包括:''.jar'],dir:'libs')
compile'c​​om.android.support:appcompat-v7:22.0.0'
compile'c​​om.google.android.gms:play-services:7.0.0'
compile'c​​om.mcxiaoke .volley:library:1. +'
compile'c​​om.google.code.gson:gson:2.2.4
compile'c​​om.android.support:cardview-v7:21.0.+'
}

我不知道什么是错的。任何帮助将不胜感激。

解决方案

我之前使用我的应用程序的调试版本和发行版本遇到同样的问题。
我在Google的开发者控制台中创建了两个条目。
其中一个用于调试版本,使用您可以从Windows主目录找到的debug.keystore
中的SHA1值。
例如

$ $ $ $ $ code用户名<

另一个版本是您使用时.jks文件中的SHA1值你创建签名的APK。



他们需要匹配,否则你将继续收到错误。



最后,当您卸载应用程序时,请不要忘记清除数据和缓存,因为这可能会导致问题。


I've tried for about a week to solve this problem. I have google maps working perfectly fine in debug, but no matter what I do when I package the apk I get this error below

05-21 21:00:21.338  31534-31613/? E/Google Maps Android API﹕ Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

I've run the following command

keytool -list -v -keystore ~/Documents/keys/phillybikeshare.jks -alias "pbs"

on two different keystores, took the SHA1 fingerprint that looks like

F9:DB:33:A2:05:02:80:5A:21:9A:19:E6:8A:E4:C4:XX:XX:XX:XX:XX

and made api keys for the SHA1 in the google developer console. I even double checked to make sure I have a variable in both main/res/values/google_maps_api.xml and debug/res/values/google_maps_api.xml yet still nothing.

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.peterchappy.phillybikeshare" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<permission
    android:name="com.peterchappy.phillybikeshare.MAPS_RECEIVE"
    android:protectionLevel="signature" />
<uses-permission android:name="com.peterchappy.phillybikeshare.MAPS_RECEIVE"/>

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" >
</uses-feature>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <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="@string/google_maps_key" />

    <activity
        android:name=".activities.MainActivity"
        android:label="@string/title_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <service
        android:name=".services.AlarmService"
        android:exported="false" >
    </service>
</application>

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.peterchappy.phillybikeshare"
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:7.0.0'
    compile 'com.mcxiaoke.volley:library:1.+'
    compile 'com.google.code.gson:gson:2.2.4'
    compile 'com.android.support:cardview-v7:21.0.+'
}

I have no idea what could be wrong. Any help would be greatly appreciated.

解决方案

I had the same issue before with my debug and release versions of my app. I created two entries in Google's developer console. One for the debug version using the SHA1 value from the debug.keystore that you can find from your home directory in Windows. e.g.

   C:\Users\<UserName\.android\debug.keystore.

And the other one, release version, is the SHA1 value from the .jks file that you used when you build the signed APK.

They need to match or else you will keep on getting that error.

And lastly, don't forget to clear data and cache when you uninstall the application as that could cause issue sometimes.

这篇关于Google Maps API v2不支持发行密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆