0
I’m creating an app for Android that uses the Google Maps API. Just that I’m having problems when I create the . apk and install on mobile, is 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 straight by Android Studio for mobile 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
This is for both debug and release?
Some 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>
Data from Google Console
That is all! kkk
Someone’s been through it?
Thank you!
When I spin by. apk from the following error: 09-18 12:03:23.691 13868-14048/com.anderson.app I/Google Maps Android API Failed to contact Google Servers. Another Attempt will be made when Connectivity is established. 09-18 12:03:23.691 13868-14048/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). When I run straight through Android Studio it works normally. but when I Gero the . apk gives this error there, why it will be?
– AndersonSouza
Dude, check out the name of your package in Android Studio. When I went to implement Google Maps, I got A LOT and after a lot of pain I paid attention that the generated package is
com.seupackage.debug
. I added . debug to the console and it worked great. Check this point! IMPORTANT DETAIL: Fully uninstall the mobile app/emulator before testing– rsicarelli
But in debug mode works perfectly, the problem is when I Gero . apk
– AndersonSouza
@Andersonsouza, if you can, put your
build.gradle
(mischaracterising sensitive data) and theAndroidManifest
also.– Wakim
Anderson, I see you wear two
keystore's
different... Within thebuild.gradle
is using theandroid.jks
and in thekeytool
is using thedebug.keystore
. Do these files have the same content? To test the exchange, you need to erase the data from the app!!– Wakim
I don’t know... kkk android.jks is the same thing as debug.Keystore? Can I use keytool with android.jks?
– AndersonSouza
It’s not the same thing no, only if the content is the same. Take a look, but you should use the same
keystore
, in case thedebug.keystore
in both places. Use thedebug.keystore
because you’ve already set it up inDeveloper Console
, change what is inbuild.gradle
.– Wakim
Cara regerei a chave utilizando o android.jks: keytool -list -Keystore C: Users Anderson Androidstudioproject s Lisandro android.jks Fui la no google console e gerei outra chave, pus na aplicação, uninstalei tudo no celular, installed again and follows the same problem! ;/
– AndersonSouza
It didn’t, it’s giving the same problem!
– AndersonSouza
I’m running out of ideas, I’ll see this later calmly, I’m leaving now. But try to update the version of your dependency on
google play services
forcom.google.android.gms:play-services:5.+
as in the documentation: http://developer.android.com/google/play-services/setup.html. Add the rules of theProguard
even if you’re not using it yet (runProguard false
).– Wakim
Cara worked!!! Thank you so much for your dedication and commitment to wanting to help me! Thanks so much! Thank you so much!
– AndersonSouza
The solution was: When using the keytool to generate the key and put it there in google console, use the same key in the build.Gradle of your application. ball show!
– AndersonSouza
@Andersonsouza, I put an explanation as an answer in case anyone comes across this problem. If there is something missing about the final solution you can edit or suggest some change.
– Wakim