google-services.json api_key is empty from firebase

1,255

First, access the Firebase Console.

Select your project, Access the "Project Settings" (Can be accessed by clicking on "Project Overview").

Now, click on the "3 dots", and then click on "Settings".

On the "Project Settings" screen, copy the "Web API Key" (Example: AIzaSyAjo3TYy8p_mjj3jMDcxTPrkwDF2dL8lwl).

Now go to your project and go to the "google-services.json" file (located under " \ android \ app \ google-services.json")

Find in the file code "google-services.json" the line with the following code:

"api_key": [],

Inside the brackets "[]" put the following code:

{
  "current_key": "<paste here your Web API Key>"
}

Paste your Web API Key between double quotation marks (see example below):

"api_key": [
    {
      "current_key": "AIzaSyAjo3TYy8p_mjj3jMDcxTsdFkwDF2dL8NWs"
    }
],
Share:
1,255
Tree
Author by

Tree

Updated on December 05, 2022

Comments

  • Tree
    Tree over 1 year

    When I followed https://codelabs.developers.google.com/codelabs/flutter-firebase/ and I downloaded google-services.json I get this error when trying to run the flutter app on android.

    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':app:processDebugGoogleServices'.
    > Missing api_key/current_key object
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 21s
    Finished with error: Gradle build failed: 1
    

    Now in my google-services.json I can see that the api_key array is emtpy:

    "api_key": [],

    I tried to download new google-services.json but with the same result.

    Anyone knows how to generate api_key?

    • Benny
      Benny almost 6 years
      have the exact same problem today. Is it a bug at firebase?
  • huggie
    huggie almost 6 years
    Why is it missing in the first place? I'm having the same problem as well. My older app does have it, but a new app I created doesn't.
  • Draško
    Draško almost 6 years
    I think that's a bug.
  • Benny
    Benny almost 6 years