Reputation: 1179
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.
Upvotes: 0
Views: 2401
Reputation: 5797
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.
Upvotes: 3