I have an app that uses google maps, in debug everything works fine, but when going to release, the map is not displayed
I have created the file google_maps.api.xml
outside of debug, that is, I have it inmain/res/values/google_maps.api.xml
in AndroidManifest.xml
it I assign it
<Aplication>
...
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
...
</aplication>
I see that inside google_maps.api.xml
there is the following:
Once you have your key (it starts with "AIza"), replace the "google_maps_key" string in this file.
And if it starts AIza
where do I get the release key?
Remember that when we obtain the API KEY it is related to the SHA-1 of our Keystore, in development the debug.keystore is used but for production you must obtain the SHA-1 of the Keystore with which you sign your application and register it .
You can even configure development and production SHA-1s to work correctly when testing in development and when signing with your keystore for the Google PlayStore.
It is important to note that adding a new SHA-1 generates a new, different API Key.
If it doesn't show you the map,
The main reason why the map is not displayed is because it does not have the correct API KEY or the api is not enabled .:
Check out this question that describes your problem, it also shows how to configure Google Maps in an Android application:
Maps Android Studio
When you set a correct API KEY and Enable the API, you should have no problem displaying the map:
Complementing solution:
The signed app must be allowed access, using the SHA1 of the signed app.
To obtain the
SHA1
you must use the commandkeytool -list -v -keystore tu_keystore.keystore
and in the google maps api panel add the name of the package with the SHA1, give save.
It has worked for me adding one more SHA-1 (apart from the one generated with the certificate). That is I have 2 SHA-1 certificate thumbprints with the same package name.
You must put the SHA-1 that comes out in the application signature of the Play Store console.
I hope it works for you, it worked for me. Cheers
When generating a Maps type Activity, TWO google_maps_api.xml files are generated, stored in TWO different folders: one for debug and one for release. I added the new google_key_map generated with the SHA-1 obtained according to the instructions provided for example in the accepted answer here. But I included it in the google_maps_api.xml file in the app/debug/res/values directory when the important thing was to include it in the app/release/res/values directory. I take this opportunity to thank all the times that stackoverflow has been of help to me.