3

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?

Darksymphony
  • 2,155
  • 30
  • 54

1 Answers1

1

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.

Darksymphony
  • 2,155
  • 30
  • 54
  • Well, works only when I install the signed apk to my device. But when I publish that same apk to store and install it from there, the maps are not working. This is very strange – Darksymphony May 15 '18 at 22:10
  • you figured out the cause? – windchime Jun 24 '18 at 17:43
  • well, not really. I read, that after publishing, somehow the fingerprint is changed. I did not figured this out. It works when I install it on my device NOT from store, but from apk, but after installing the same apk from the store, it works not. So for now I removed the authentification in google console. I know it can be a security risk, but at least it works. – Darksymphony Jun 25 '18 at 19:13
  • 1
    i found out the fingerprint of the published apk from error logging after downloading it to my device and added it to google console. it worked that way. – windchime Jun 28 '18 at 18:31
  • you mean you published the app and downloaded from the store, and then you checked the error log? Do you have some app which shows the error logs on mobile device? Maybe this can be a good way to fix my issue. However, the problem is, that after publish the users won't have a working map untill I fix it – Darksymphony Jun 30 '18 at 06:07
  • there is no longer debug or release folder inside the src. This is outdated answer. – coolcool1994 Feb 14 '21 at 17:28
  • yes, the answer is from 2018. The solution is to find the correct fingerprint of your live app in Google console and use that in google maps API webpage. – Darksymphony Feb 14 '21 at 18:59