I'm creating an Android app that uses the Google Maps API. But I'm having problems when I create .apk and install it on my phone, giving this error:
09-18 16:05:07.631 18129-18238/com.anderson.app 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).
But if I run running directly through Android Studio the phone is working perfectly.
NOTE: When I created SHA1 to put it on google console I did so:
keytool -list -keystore C:\Users\Anderson\AndroidStudioProjects\Lisandro\android.jks
Does this serve both debug and release?
More information ...
build.gradle
apply plugin: 'com.android.application'
android {
signingConfigs {
android {
keyAlias 'android'
keyPassword 'android'
storeFile file('C:/Users/Anderson/AndroidStudioProjects/Lisandro/android.jks')
storePassword 'android'
}
}
compileSdkVersion 'Google Inc.:Google APIs:19'
buildToolsVersion '20.0.0'
defaultConfig {
applicationId 'com.anderson.lisandro'
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.android
debuggable false
jniDebugBuild false
}
debug {
signingConfig signingConfigs.android
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:appcompat-v7:20.0.0'
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.anderson.lisandro" >
<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="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--\
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyA1ad9...lO5pAoidaVA" />
</application>
</manifest>
Google Console data
That's all! kkk
Has anyone ever been through this?
Thank you!