Android google maps release key?

前端 未结 4 1006
心在旅途
心在旅途 2020-12-19 15:24

How do I get a release key for Google Maps? I used my current key with a debug.apk and a signed-release.apk, and the maps dont render on the release.apk, so I assume its a A

相关标签:
4条回答
  • 2020-12-19 16:07

    Just add string not from resources(@string/google_maps_key), but hardcode.

    <meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="AIza..." />
    
    0 讨论(0)
  • 2020-12-19 16:07

    From How to configure Google Maps API keys for Android by Dragana Vucic:

    Go to Google API Console -> APIs & Services -> Credentials and click on Create Credentials -> API key. This option will generate a key that is not restricted to anything (yet).

    1. Copy this generated key and click close
    2. In Android Studio: Build -> Select Build Variant -> release
    3. Open file res/values/google_maps_api.xml(release) and paste generated key
    4. Publish app
    5. Go to https://play.google.com/console/developers and select your publich app
    6. Go to page: release management -> app signing
    7. copy SHA-1 certificate fingerprint
    8. Return to https://console.developers.google.com/apis/credentials
    9. Click on release key. In "Key restrictions" section to select "Android Apps"
    10. In "Restrict usage to your Android apps" section enter package name and SHA-1 from Google play console
    11. In "API restriction" section select -> Restrict key -> 1 API.
    12. Click Save

    After these steps, the google map service will work for the published application.

    0 讨论(0)
  • 2020-12-19 16:28

    The same way you get a "debug" key. There is no real difference, just as there is no real difference between a debug and a release certificate in Android (except that the debug certificate gets created automatically for you and resides in your Android settings folder).

    Get the SHA-1 fingerprint for your Android release key and use it along with the proper package name (debug builds usually have a ".debug" attached, so make sure to omit that) to create a new Google Maps Key in the Google Developer Console.

    0 讨论(0)
  • 2020-12-19 16:29
    1. You have to enable Google Maps API here:

    https://console.developers.google.com/apis/dashboard

    1. You have to create key here:

    https://console.developers.google.com/apis/credentials/oauthclient?

    1. Put your key into AndroidManifest.xml file.

    That's it!

    More detailed:

    https://developers.google.com/maps/documentation/android-api/config?hl=en

    0 讨论(0)
提交回复
热议问题