Missing api_key/current key with Google Services 3.0.0

后端 未结 17 870
小鲜肉
小鲜肉 2020-12-02 07:20

Since I upgraded the project with the latest version of google services and libraries (9.0.0), I have this strange issue :

Grade console :

:         


        
相关标签:
17条回答
  • 2020-12-02 07:50

    I was able to solve this problem with these steps that are not answered here. This answer is NOT enabling Cloud Messaging, it is only retrieving its server key.

    So first, go to Firebase Console, and then go to Project Settings, and then click on the tab "Cloud Messaging". Look where it says "server key" and if there is no long key displaying (not the "Sender ID" number) click "Regenerate Key" and a long key should now show. Copy that key and place it in your google-services.json file at: "api_key": [ {"current_key" : "key goes here"} ].

    This method helped me while none of the others were working, so hopefully this helps someone.

    0 讨论(0)
  • 2020-12-02 07:53

    You can download the google-services.json file again.

    Steps to download:

    1). Click on the top menu in your app in the Firebase Console.

    2). Click on manage.

    3). You will find Download the latest config file option, download and replace the google-services.json file in your application.

    0 讨论(0)
  • 2020-12-02 07:55

    If you don't want to reconfigure and download the google-services.json file then you can fetch the api key directly from firebase console. Just go to

    Overview > Add another App > Web

    You will get configuration for your database which will contain apiKey. Just copy that value and place it in the current_key value denoted by XXX below

    "api_key": [{ "current_key": "XXX" }]
    
    0 讨论(0)
  • 2020-12-02 07:56

    If you are not using Firebase, the correct link to generate the google-services.json config file is actually found here.

    0 讨论(0)
  • 2020-12-02 07:58

    Using Firebase

    GoogleServices'. > Missing api_key/current_key object
    

    I got this error after updating an existing project to the new Firebase Services. The generated google-service.json file downloaded from the firebase project settings page did not include the api_key needed.

    From the other answers here it looks like Google/Firebase Cloud Messaging (GCM/FCM) needs to be added for this api_key to be included in the google-service.json file.

    So I added a dependencies on the firebase FCM before downloading the file again, and this time the key was included.

    Include FCM (GCM)

    dependencies {
         compile 'com.google.firebase:firebase-messaging:9.0.0'
    }
    
    0 讨论(0)
  • 2020-12-02 08:01

    For everyone that have this issue, for now, you'll need to add any service to your app at https://developers.google.com/cloud-messaging/android/client#get-config

    In my case I have added admob (already have analytics and gcm) and then the file was generated with api_key.

    I think's it's a bug and will be soon fixed, until that, do it.

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