morganzd
morganzd

Reputation: 537

Google map still blank on real Android device on release apk

I want to generate and use a google API key.

  1. enabled google maps v2 API
  2. created project with one activity with google map (default wizard in studio)
  3. created key on google for debug project, assigned SHA1;app package of application to the project key on google
  4. API key inserted into google_maps_api.xml (AndroidManifest.xml updated automaticaly)
  5. build & run on AVD on which the app is working, map is shown.

Then:

  1. API already enabled
  2. in Android studio created keystore for release (keystore.rel.jks)
  3. generated fingerprints (keytool -list -v -keystore C:\Dropbox\AndroidKeyStore\keystore.rel.jks)
  4. on google added new fingerprint to the new release project (release SHA1;app package) - key generated AIza...
  5. API key inserted into google_maps_api.xml (AndroidManifest.xml updated automatically)
  6. generate signed app (using keystore.rel.jks) & install on real device ... app is working, map is STILL BLANK, only zoom buttons and Google label is on

Upvotes: 42

Views: 71494

Answers (10)

Sweta Jain
Sweta Jain

Reputation: 4324

Please follow these steps:

  1. Go to Google Play Console -> Setup -> App integrity -> App signing key certificate
  2. Copy the SHA-1 certificate fingerprint
  3. Open Google Cloud Platform
  4. Go to APIs & Services -> Credentials
  5. Click on your API key
  6. Go to Application restrictions -> Restrict usage to your Android apps
  7. Click on ADD AN ITEM
  8. Add your package name with the copied SHA-1 certificate fingerprint
  9. Wait for around 10 mins. and your maps would be visible on your published app.

enter image description here

enter image description here

Upvotes: 0

InternationalCodingGuru
InternationalCodingGuru

Reputation: 2258

Make sure you enable the Maps for Android app in Google Console.

Upvotes: 1

Jaime Montoya
Jaime Montoya

Reputation: 7701

Go to https://play.google.com/apps/publish/ and then to App signing:

enter image description here

Maybe you will see this:

enter image description here

If that is the case, maybe you are a developer and not the account owner. You will have to contact the account owner and ask him/her to complete that process. Follow this article about how to do that:

https://learnfreecoding.com/how-to-sign-your-android-app-with-signed-key-private_key-pepk/

The account owner will get to this screen:

enter image description here

Ask them to choose Upload a key exported from Android Studio. They will have to upload a private_key.pepk file. This is how you get that file from Android Studio:

  • Go to Build > Generate Signed Bundle / APK....

enter image description here

Select Android App Bundle and click Next:

enter image description here

Provide the corresponding credentials and make sure to put the check on for Export encrypted key for enrolling published apps in Google Play App Signing.

enter image description here

Specify the destination folder and make sure you select release before you click Finish:

enter image description here

That will generate the private_key.pepk file that you need to provide to Upload a key exported from Android Studio.

After doing the above, when you to to the App signing section of your app, you will see something like this:

enter image description here

Then you will see the Google Maps working correctly on real Android Studio physical devices and not only on the Android Studio Emulator. This was the solution for me.

Upvotes: 2

masoud jafari
masoud jafari

Reputation: 592

generally you must do below steps:

1- Create New maps Activity in android studio

2- In google_maps_api.xml open the link in line 3

3- Confirm data and get key in Firebase

4- Copy key in google_maps_api.xml debug and release

5- Get release SHA1 in gradle tab -> signing report

useful link for get sha1

useful link for sign application in debug mode to get sha1

Upvotes: 1

Md. Shofiulla
Md. Shofiulla

Reputation: 2305

When you try to create map api key please make sure the url contain correct package name. It should not take any sub package like this.

wrong package :com.gpslocation.trackerpro.Activities


correct package :com.gpslocation.trackerpro

enter image description here

After editing don't forget to save

Upvotes: 3

vijaycaimi
vijaycaimi

Reputation: 317

enter image description hereI faced the same problem, in my case fingerprint of my package used in google map API key was mismatched so what i did:

  • Create a new google map activity.
  • Go to google_maps_api.xml.
  • Copy the link given in that file in paste in browser(login to google account).
  • On google create some project here and press continue
  • Click on create API key
  • Copy the key and paste in google_maps_api.xml

    string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"YOUR KEY HERE

And execute the application

Do not use below fingerprint, or key, create your separate it is based on package ans application

Upvotes: 0

Full-Fledged
Full-Fledged

Reputation: 309

Got stuck on this issue for a day. I tried everything and eventually found the following code in my manifest:

<supports-screens
   android:anyDensity="false"
   android:largeScreens="true"
   android:normalScreens="true"
   android:smallScreens="false"
   android:xlargeScreens="true" />

After removing these lines my maps displayed correctly.

Upvotes: 0

Andres Felipe
Andres Felipe

Reputation: 4330

i was tired of trying over and over again, it turns out that PlayStore has something called App signing certificate, and the map works after i copy that sha1 and paste it in the google console for the android map.

Upvotes: 13

shehzy
shehzy

Reputation: 2281

Make sure the map key you entered in google_maps_api.xml file is the same android key, generated by google console.

You can also try a new key.

Upvotes: 0

Daniel Nugent
Daniel Nugent

Reputation: 43322

Make sure you enter your release API key in the google_maps_api.xml under the release folder.

First, switch to Project view by using the dropdown in the upper left of the Project Explorer. Then, expand app/src/, and you will see subfolders debug and release. Under there, you should see two separate google_maps_api.xml files under debug/res/values and release/res/values.

Make sure that the release API key is in the google_maps_api.xml file under the release/res/values folder, since this is the one that will be used for the signed release apk.

enter image description here

Upvotes: 85

Related Questions