Google Maps not displaying in release build - android

I'm getting this error: Failed to connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
Not sure what I'm doing wrong. I have two SHA-1 fingerprints (one from debug keystore, one from the release keystore) in the Android app within the Google API's console.
The map displays fine in debug mode however.
Basically I did everything in this document so far:
https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key

If it's working in the debug version and not the release version it may be that you forgot to change the API key in your manifest file. Make sure that the API key you're using in your AndroidManifest.xml file is the same one that is associated with the Google Developer's Console that corresponds with the Release version of your application and not the debug version.
This is the line in your manifest that I'm referring to:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="API_KEY"/>

Related

Android google maps not working after publish

I have a google map in my app, but it is not working when I create a release signed app.
I tried everything what I've found here, with no luck.
I obtained the SHA1 fingerprint .\keytool -list -keystore C:\Users...signature.jks
It showed me the SHA1 fingerprint 98:EC:9D...
So in Google console under Maps SDK for Android I added my packagename and this fingerprint. I took the API key from there and put it in my app, into google_maps_api.xml, and in my Manifest I have this:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
I tested this with attached device and the debugger says:
Authorization failure.
E/Google Maps Android API: Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: AIzaSyD........
Android Application (<cert_fingerprint>;<package_name>): B7:06:CC:...;mypackage
So the map is not working, neither when I build the signed app.
As you can see, there is a total different fingerprint in the log, not sure from where.
Ok, so then I put that fingerprint (B7:06:CC...) to my Google console, and then the maps are working on my attached device without errors, BUT the map is not working when I create a signed APK!
Am I doing something wrong?
Ah, I finally found out! There are 2 different google_maps_api.xml files. One is in debug/res/values folder and the 2nd in release/res/values folder and that one in release folder had no API entered!
So one is used when debugging and the other for release.
So now it is working fine.

Why Google Maps is not being shown in production?

I am uploading an APP to Play Store. It is being uploaded well but there is one inconvenience, the maps that I am using is showing on debug mode but not when I use my application on production (when I upload the APP to the market and download it from there). A grey screen is shown when I try to open the map. I am using Google Maps.
What I have done:
I have created a release profile to sign my APK that I use when I generate my APK. To sign the APK I do (on Android Studio) Build > Generate Signed APK with the Name, Alias and Password of my certificate profile.
I have generated a Google Maps API credential using SHA-1 of the certificate that I have created in the step before and the name of the package of my project. I have restricted it to only be allowed on Android. It have generated a key to me.
I have added these two lines on AndroidManifest.xml file of my project:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
where #string/google_maps_key is the key that I have obtained in the second step and that I have stored in strings.xml file.
I know that there are some questions related in Stackoverflow but most of them suggest generate one of both certificates that I have already created.
Am I missing some requirement? Should I change some configuration?
Thanks in advance!
When you generated your Google maps key, did you put SHA-1 of your debug, or of your release certificate? If you put debug SHA-1, add release also.
Update:
Also, proper way to do map implementation would be to have debug/res/values/google_maps_api.xml with key for debug and another release/res/values/google_maps_api.xml with key for production. There shouldn't be key in strings.xml. More about this you can read here.

Google Maps V2 not working in production with correct key

I'm having major troubles getting Google Maps working in production within an Android app. This is what I am currently getting (the bottom is just ads).
Key Steps I have followed:
1) I have ensured I have got the correct SHA1 Production Key and have implemented it on the Google Console API as well as within the app (They key that google gives). I have registered two keys - one for the debug and one for production
2) Internet, location, etc is working
3) The app works in DEBUG mode, but does not work when signed and installed on device via USB. I have triple checked the SHA 1 signature of the sign, etc.
4) The MapsFragment comes from the template available in Android Studio.
In production mode, the log cat displays this:
01-11 16:04:54.511 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-11 16:04:54.516 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: YOUR_KEY_HERE
Android Application (<cert_fingerprint>;<package_name>): <SHA1 Removed for this> ;com.mike.mapstest
This error obviously says something is wrong with my auth?
What am I doing wrong?
Based on the logcat output from your debuggable release build:
01-11 16:04:54.511 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
01-11 16:04:54.516 19346-19437/com.mike.mapstest E/Google Maps Android API﹕ In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: YOUR_KEY_HERE
Android Application (<cert_fingerprint>;<package_name>): <SHA1 Removed for this> ;com.mike.mapstest
it would appear that you have not overridden the api key placeholder YOUR_KEY_HERE in the manifest (or separate api keys file, depending on your configuration). Replace that string, wherever it lives, with your actual key and you should be good to go.
Edit: this tutorial, if it matches your configuration, probably explains why you are only seeing this for release builds:
Return to Android Studio and paste the API key into the YOUR_KEY_HERE section of the file:
Note that these steps have enabled Google Maps support for the debug version of the application package. The API key will also need to be added to the google_maps_api.xml file located in MapDemo -> app -> src -> release -> res -> values when the release version of the application is ready to be built.
I was having these same issues, and was banging my head against the wall for a few days. I read all the posts about putting the correct key in place. I kept putting the correct key in my google_maps_api.xml file. StKent above mentioned to make sure to overwrite with the actual string in AndroidManifest.xml. This is what fixed it for me.
What I had when it didn't work:
in AndroidManifest.xml:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
and in google_maps_api.xml:
<string name="google_maps_key"
templateMergeStrategy="preserve"
translatable="false">AIza_the actual key</string>
What I changed to for it to work
I changed my AndroidManifest.xml to include:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzsa_the actual key" />
When using Android Studio to generate the Google Maps Activity, it will ignore your gradle build configs and use the default debug.keystore. The SHA1 in google_maps_api.xml is based off of this default. When creating permission in the Google API console, make sure to use your production and debug SHA1 if you are using the non default.
debug and production key will be different . If you use debug key for release mode ,you can not view the google map. For release mode , when you change google map key , you should clean the project then export apk.
you can get more information
https://developers.google.com/maps/documentation/android/start
to get private SHA1 from debug key store
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass your_app_password
to see more
SHA-1 fingerprint of keystore certificate
or you can you eclipse tool to generate private SHA1 key using export menu
In my case, I had entered the wrong package name in Google API's API Manager - Credentials - "Restrict usage to your Android apps". Make sure you enter the correct package name (as in AndroidManifest.xml) and the correct SHA fingerprints (for debug and production).
Solved, I put on the Manifest the "Key for browser apps (with referers)" instead of the "Key for Android apps (with certificates)" from the Google API Console
In my case, the gray screen was caused by having a custom implementation of HostnameVerifier that was preventing the tiles from being loaded.
Hope this will help someone else in the future.
error //Ensure that the "Google Maps Android API v2" is enabled.
In this u can't find like Google Maps Android API v2 in Google Cloud Platform Console.in this, give the exact Package Name: and signature of your project which is showing in run window or debug window , I faced the same problem because of changing MapActivity package location
I struggled to find this whole day so make sure whether u changed any packages inside project if so give package which is showing in error text
emphasized text
Ensure that the following Android Key exists:
API Key: YOUR_KEY_HERE
Android Application (;): ;com.mike.mapstest

Google Maps Android API keystore

In my app, I use maps to show the current position. Then, I use Google Maps Android API v2 (I don’t use Google Maps API) to add this functionality to my app.
When I am developing my app in eclipse everything is OK. I create an Android key with the debug keystore and I use it in the manifest, I can execute my app well and I can move and use the map. In this case I have no log errors (only the typical “The Google Play services resources were not found. Check your project configuration to ensure that the resources are included”).
Now when I upload my app to the Google Play Developer Console, in beta testing it works, but when I go publish, the map gets grey background and doesn’t work. Log gives me this error:
09-23 14:05:46.475: E/Google Maps Android API(5485): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
09-23 14:05:46.475: E/Google Maps Android API(5485): Ensure that the following correspond to what is in the API Console: Package Name: gc.yy.xxxx, API Key: AIza*******************************RDEI, Certificate Fingerprint: 472D********************************7218 (keystore use to sign the package)
Then I decide to use in my eclipse project that keystore, so I create a new Android key (47:2D:*************************:72:18;gc.yy.xxxx gives me AIza*****************Qm4Q key) and I paste it in the manifest file. I run the project and I get once again the grey background. Log gives me this error:
09-23 14:10:45.307: E/Google Maps Android API(5585): Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
09-23 14:10:45.317: E/Google Maps Android API(5585): Ensure that the following correspond to what is in the API Console: Package Name: gc.yy.xxxx, API Key: AIza*******************************Qm4Q, Certificate Fingerprint: CC4B********************************A917 (debug keystore)
I don’t know if the problems concerns to the keystore. I use debug.keystore with my map (I can’t use another one, I don’t know if it’s not possible) and I use a keystore I create to sign my app package. It seems an infinite loop of no useful API keys…
Thanks in advance!
EDIT: I finally solved it by adding the 2 meta-data blocks of each API key, that is to say, my manifest was like this:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIza*******************************RDEI" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIza*******************************Qm4Q" />
And finally, I have my app in Google Play! :)
You need to register your non-debug keystore to the google maps API via the Google API console
I used two different api keys (one for development, one for the release). At the end: that's stupid, since you can have several app hashes attached to one key. Hence that's the solution, just added on code.google.com/apis/console the release hash to the development api key (for backwards compatibility) and the development hash to the release api key (for easier development).

Google maps v2 android api key working only with debug key

I have a problem with Google Maps api v2 on my android app.
I have generated the key for the debug certificate and everything works fine, but I can't make it work with the release certificate.
I've generated the key and the alias with eclipse, then I took the SHA1 which eclipse shows at the end of the "Export signed application" process.
Then I generated the api key for android apps in my google api console using
SHA1;package name
But it doesn't work... it works only with the debug key generated in the same way, only using the sha1 of the debug certificate!
Please help me, otherwise I can't release my app
Check your manifest file, I guess you've forgotten to set your release map api key there while exporting with your release key?
Me too faced the same problem during releasing my app to google Play, when I used Google Maps V2 in my app. After succeeding the issue, I wrote a blog post regarding this you can have a look.
As everyone requested, I would say the answer in following steps
1) Sign up your app using eclipse adt
2) Note down the SHA1 finger print which will be displayed at console of your eclipse adt
3) Again go to google console and get API_KEY for your app by using above got SHA1 fingerprint
4) Replace the old API_KEY with the new API_KEY on to manifest.xml of your app
5) Again sign up your app. Your app is ready to be published. But keep in mind that once you published your app to google market, you should be able to release updates to your app by signing .apk using the keystore which you used earlier for release.
Hope this helps ...
There are two files google maps api.xml, one is the debug and release the other, then you should replace the key generated on google website console and enter this file, another outlet is inserted directly into the manifest.

Categories

Resources