31

I am using the Google Maps Android API and I'm running into some issues.

I am signing my apk with android studio (created one at .android/keystore.jks). Also I'm selecting "release" as type in it. I have used the command

keytool -list -v -keystore C:\Users\Toshiba\.android\keystore.jks

to get the SHA1 fingerprint out of the keystore.

The SHA1 is correct, but the Map is not shown on a signed APK. It is shown in a debug APK.

Using keytool with the release keystore (keystore.jks) will get me this:

 SHA1: 33:46:07:82:5B:D4:45:D2:60:CE:5A:29:97:9F:6C:44:XX:XX:XX:XX

The debug one works fine (I have added 2 to the API console in Google)

33:46:07:82:5B:D4:45:D2:60:CE:5A:29:97:9F:6C:44:XX:XX:XX:XX;yac.breakingpoint
7C:28:61:5B:C3:4A:5C:50:44:AA:FD:58:69:E9:70:91:XX:XX:XX:XX;yac.breakingpoint

XX is blacked out.

The keytool says it is using SHA256withRSA as signature algorithm for both, the debug and the release keystore.

What am I doing wrong?

UPDATE So I've tried a new API key, clean project and rebuild it, new keystore - still not working on release... debug is fine!

UPDATE 2 Still not found a working solution... Help me!

UPDATE 3 Allright, got it working using a signed APK with build type debug. Extracted the CERT.RSA and runned keytool -printcert -file ./CERT.SA. Got the same result as for the release build type. In release it is not working!

UPDATE 4 Here's another try I made:

  • Created a new GIT Repository, commited to it.
  • The /buildfolders are not beeing commited since they are in the .gitignore files.
  • Created a new API key in the API console and added only the release SHA1 key to it.
  • Added that API key to the app and made a full clean with rebuild.
  • Generated a new signed APK file

It did not work.

UPDATE 5 A friend of mine tried to reproduce this issue. He has the exact same issue when working with android studio. Probably a android studio bug?

amahrt
  • 523
  • 1
  • 5
  • 13

5 Answers5

76

You have two google_maps_api.xml files

One in this folder:

app/src/debug/res/values

Other in this folder:

app/src/release/res/values

But only the debug one contains your API key probably.

LamaTo
  • 540
  • 1
  • 8
  • 21
suhaig
  • 776
  • 6
  • 3
  • 6
    Holy cow!! I just can't believe it! Thanks so much. There was a file `app/src/release/res/values/google_maps_api.xml` which contained the default value.. It works! – amahrt Nov 21 '14 at 18:54
  • Had same issues, had tried everything, this worked. Thanks. app/src/release/res/values/google_maps_api.xml was empty, there was no key. I ha used Alt+Click in the AndroidManifest.xml file to add the api key and it only added it to the debug. – Joseph Mar 12 '15 at 14:59
  • 2
    Thhhhhhhhaaaaaaaaaank you!!! I lost two days and have tried everything i really want to kiss right now! I always open with the CTRL+SHIFT+N and i have never noticed that there was two differente files, always a fast hit ENTER. – Henrique Goulart Jun 10 '15 at 02:40
  • Hahaha!! I wasted two days too! Holy crp, I even did not notice the gray (debug) word near the google_maps_api.xml! Happy New Year for all! – Alexandr Dec 31 '15 at 17:58
  • thanks soo much. but im wondering why was only the debug version appearing under the values directory (in case im on the Android view on Android Studio) – SoliQuiD Jan 19 '16 at 16:42
  • you saved my life, thank you so much. i wasted almost 4 hours just to fix this and i found this answer. – klaudiusnaban Jan 22 '16 at 21:35
  • 1
    I have some problem but in my app folder not have relase or debug folder.. do you know other answer? – Eggy Jul 21 '16 at 07:59
  • This helped me! Thanks – Mark O'Sullivan Nov 16 '16 at 09:26
  • This saved me! Thanks! I ended up just moving the file in the debug directory to the main directory and deleted the file in the release directory. This way I only ever have 1 file to edit. – compman2408 Nov 02 '17 at 17:22
3

1) Usually, you have to Clean and Rebuild the Project so it can work.

2) Make sure your build variant is on Release (Android Studio is friendly on this)

3) Also if you are debugging on your devices fully uninstall first then continue.

4) As the documentation says, make sure you have set up your manifest correctly.

Hope it helps.

Uniruddh
  • 4,427
  • 3
  • 52
  • 86
Joel
  • 838
  • 5
  • 12
  • I've checked out all of your points, but nothing worked. The Manifest is setup correctly, because it is working on debug mode I guess. – amahrt Sep 16 '14 at 12:31
1

Create new project in Android Studio with Google map Activity. After project automatically creates the SHA1 in the manifest. Use this SHA1 to get MAP api key. Test your app be sure it works. And after build you app on what project.

ArmDroid
  • 209
  • 1
  • 11
  • 1
    This is not true, there is no SHA1 in the manifest. Android Studio does create a file called `google_maps_api.xml` with the debug SHA1 in it. Thank you for trying. – amahrt Sep 17 '14 at 18:13
  • Yes you are right. What file for key, and SHA1 on it in comment line. – ArmDroid Sep 17 '14 at 18:20
1

the SHA1 currently you are using for debugging purpose .

So when you are creating a signed apk u have one kestore file. try to generate new SHA1 key with this new keaystore file.

then using this keystore file create API key for signed apk from google console.

replace debug API key already stored in manifest file with the new one.

It will work

thanks

Arun Antoney
  • 4,292
  • 2
  • 20
  • 26
  • This is not true, I am not using the debug keystore.. Please read the question properly.. – amahrt Oct 27 '14 at 10:13
  • Hi I am not well in android studio but the error that you reported simply states that the error is with keystore file.The answer is based on eclipse – Arun Antoney Oct 27 '14 at 10:15
  • I am using a different keystore, and am signing with this. I got the SHA1 from that keystore AND exported it from the apk itself. It just won't work in release. I can also sign it as "debug" type with the release keystore and it will work. I think it's a android studio related bug. – amahrt Oct 27 '14 at 10:17
1

You also need to add SHA-1 generated by Google App signing certificate.

Once you publish your app you can find it in Google Play Console -> Development Tools -> Release management -> App signing -> App signing certificate.

More details on this in this here: Google Places for Android API key does not work on app from Play Store