Android: Google Map v2 not showing map for release apk

后端 未结 16 1586
感情败类
感情败类 2020-12-08 16:04

My google map app works fine on device with debug google map API KEY but when I create signed apk for my app with release google map API KEY, it does not display map. To gen

16条回答
  •  情歌与酒
    2020-12-08 16:17

    Google key has two types of Security.

    1.Non restricted key
    2.Restricted key (Android restricted through SHA-1)

    Note: Use Restricted key for Maps,Places, but not for Google Directions. use Non restricted api key for google Directions . bcz its web based api response so restricted key doesnt work.

    -> When using Non Restricted key

    • look into two google_maps_api.xml files, one in the app/src/debug/res/values folder and the other in the app/src/release/res/values folder, but only the debug one contains your API key. make sure key is same in both files.

    -> When usingRestricted (Android SHA-1) key

    • Step - 1 : look into two google_maps_api.xml files, one in the app/src/debug/res/values folder and the other in the app/src/release/res/values folder, but only the debug one contains your API key. make sure key is same in both files.

    • Step - 2 : Generate SHA-1 using AndroidStudio (gradle tab in Left Pane and select signing Report) and add as a item in google Developer console for the Api key which your using.

    • Step - 3: As soon as you generated Signed Apk google will overwrite your Androidstudio generated SHA-1 a with google own SHA-1 key. so u need to get tht also to be added for Api key in Api key in Developer console

      Goto Release Management -> App Signing -> and copy the SHA-1 certificate fingerprint from App signing certificate

      Paste this newly copied SHA-1 fingerprint to Developer Console and map in release mode will show.

    • Step 4: Add Release build SHA-1 also to Api key in Developer console like below.

      Goto Release Management -> App Signing -> and copy the SHA-1 certificate fingerprint from Upload certificate

      Paste this newly copied SHA-1 fingerprint to Developer Console and map in release mode will show.

提交回复
热议问题