Release an APK file that doesn't display Google maps

I applied the exact steps as mentioned in the Google developer document to create an example Google map project, and everything went fine on the emulator, but when I generated the project apk file and ran it on a real device, the Samsung Galaxy S4 Google map doesn’t show up, it shows only an empty background with only a colored Google logo appearing in the lower left corner of the screen !!

I created a new project for a Google map. I created a new .jks file for the project, created a repository, password, and alias, then extracted SHA1 from the cmd Java bean. I went to dev.google.com/console, created a new project, then turned on Google maps. The Android API then created an API key from Credentials and inserted that API key in google_maps_api.xml. In my project, the release of signatureConfigs has been updated with the path to the .jks file, an alias, and two passwords. then generated a signed APK from Android Studio, then transferred app-release.apk to the real device, then fixed the same problem, but the Google map does NOT show.

+21
source share
8 answers

Reason for this problem

This is because there are different SHA1 in the debug and release types.

Fix this problem

Add the SHA1 the keystore used to build the release APK into the Google console

Steps :

  1. Get the path to the keystore when creating a signed APK

    Build → Create Signed APK ..

Save the path to the keystore

enter image description here

Remember to make Build Type --- release

enter image description here

  1. Retrieve SHA1 from the keystore.

Open the terminal use command below:

  keytool -list -v -keystore "/Users/NT/Desktop/generalkey.jks" 

You will be asked to enter a password for your keystore.

Change the path to your keystore keytool -list -v -keystore "keystore path"

From the fingerprint of the certificate you will see SHA1

  1. Generate Android key using this SHA1 and your package name

enter image description here

Create an APK using a keystore and enjoy the map

+31
source

It might be silly, but my API key is included in

app\src\debug\res\values\google_maps_api.xml(debug)

You must also enable in-

app\src\release\res\values\google_maps_api.xml(release)

+6
source

if anyone else encounters this problem:

this happened to me because we need two google maps api keys, one for debugging and one for release, you can check:

C: \ Users \ username \ AndroidStudioProjects \ yourapp \ app \ src \ debug \ res \ values, and you will find XML with your API key, for example:

  <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIza...etc</string> 

but if you check here:

C: \ Users \ username \ AndroidStudioProjects \ yourapp \ app \ src \ release \ res \ values ​​you will find XML, but without an API key inside, for example:

  <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">YOUR_KEY_HERE</string> 

this was noted as a comment inside the xml file itself:

Before you release the app, you need the Google Maps API key.

 To do this, you can either add your release key credentials to your existing key, or create a new key. Note that this file specifies the API key for the release build target. If you have previously set up a key for the debug target with the debug signing certificate, you will also need to set up a key for your release certificate. Follow the directions here: https://developers.google.com/maps/documentation/android/signup Once you have your key (it starts with "AIza"), replace the "google_maps_key" string in this file. 
+3
source

Check the following:

  • This file below should be in both debug and release versions

     app\src\debug\res\values\google_maps_api.xml (debug) 

    You should also include in

     app\src\release\res\values\google_maps_api.xml (release) 
  • Add SHA1 to release apk in the Google Api console.
    You can get the SHA1 key in the game console >> Signing the application >> SHA1 certificate

+2
source

now google signed apk before publishing in the store, so go to the google app goish app ---> app signning and add the signed key to the google developer console, you will add 3 sha1 keys: debug, release and a new sha1 key after pushlish

+1
source

Another additional step: In the Google Play Developer Console, add the signature of the SHA1 application: enter image description here

+1
source

If all of the above cases do not work, then the method used below works for me. To do this, enable the signature on Google Play

0
source

I also had the same map problem, when I make apk, make apk on the same system where you made the Google map key, then the map will work and display perfectly.

0
source

Source: https://habr.com/ru/post/1235927/


All Articles