Android Studio - Google map still blank on real An

2019-01-01 06:04发布

问题:

googled it, read millions of advices about how to generate google API key, how to use it but nothing works!

  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

Thanks in advance for any advice.

Zdenek

回答1:

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



回答2:

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.



回答3:

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.



回答4:

\"enterI 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



回答5:

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

After editing don\'t forget to save



回答6:

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.