Android: Google Map v2 not showing map for release apk

后端 未结 16 1388
感情败类
感情败类 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:32

    If you are created SHA1 code from custom keystore use the same in release mode. or generate apk by signing with that same keystore and test.

    Before that you need clear app data (Setting->App-select app-Clear data->uninstall) and try. this worked for me. Ensure that package name is same as that in google developer console.

    0 讨论(0)
  • 2020-12-08 16:34

    Debug certificate is different from your production certificate. You need to add both to your Google Maps key entry in your API console as seaparate row - each with the same packageId, but naturally different SHA1 hash.

    EDIT

    There's no limit of how many certificate fingerprints and package names are assigned to single Google Maps key, so unless you need this separated is's perfectly fine to have both development and production builds using the same key. In google console it would be like this (one sha1 is from debug cert, which is the same for all apps you build using this IDE, other is production cert):

    83:10:58:52:EF:3B:59:70:2B:28:9E:AE:4F:5E:1D:F0:7E:19:FB:F1;com.foo.bar
    AE:4F:5E:1D:F0:7E:19:FB:83:10:58:52:EF:3B:59:70:2B:28:9E:AA;com.foo.bar
    

    or even (but I do not recommend using same key for different apps):

    83:10:58:52:EF:3B:59:70:2B:28:9E:AE:4F:5E:1D:F0:7E:19:FB:F1;com.foobar.myapp
    AE:4F:5E:1D:F0:7E:19:FB:83:10:58:52:EF:3B:59:70:2B:28:9E:AA;com.foo.bar
    EF:3B:59:7E:19:FB:83:10:58:57:AE:4F:5E:1D:F0:2B:28:DE:9E:01;net.something.otherapp
    
    0 讨论(0)
  • 2020-12-08 16:35
    create another Maps API key (to put in your manifest) corresponding with you release   
    keystore for release.
    

    check Google's documentation

    0 讨论(0)
  • 2020-12-08 16:38

    Below method worked for me:

    • Put google maps api key in manifest as hardcoded text mentioned by @Florence Herrou

    Android Studio creates inside:

    app\src\debug\res\values\google_maps_api.xml (debug) //add key here
    

    Add key inside ->

    app\src\release\res\values\google_maps_api.xml (release) //add key here
    
    0 讨论(0)
提交回复
热议问题