Fixing the Missing api_key / current_key #bug in #Firebase

When using the Android Studio Firebase tools, I’ve noticed from time to time the ‘Missing api_key/ current_key’ can cause gradle sync to fail. This is quite annoying, but thankfully easy to fix.

Follow these steps to get around it:

Find your Project in the Firebase Console:

When using the assistant, when you did the ‘Connect your app to Firebase’ step, you gave the app a name on Firebase. Go to the firebase console (console.firebase.google.com), and find the tile representing the app. So, for example, when I was writing my FCM blog series, I created a Firebase app called ‘LaurenceBlogFCMDemo’. When visiting the Firebase Console, I’d see a tile like this:

When you select it, you’re taken to the Overview screen, and you’ll see another tile for the android app that this Firebase project uses:

Get the Google-Services.json file

Click the three dots on this tile, and you’ll see a popup menu.

Click ‘Settings’, and you’ll be taken to a screen that lists the project settings. Near the bototm of this screen, on the right, you’ll see a button to download ‘google-services.json’

Click it, and the json file will be downloaded to your computer.

Add Google-Services.json to your project

When using Android studio, the project explorer has a number of views. It typically defaults to ‘Android’, showing you folders for your source code, layouts etc. Before you try to add Google-Services.json into your app, it’s best to switch to ‘Project Files’ view — which is more of a raw layout of how the files exist on your disk:

Once you’ve done this, you’ll see your existing Google-services.json file in your app folder:

Now, drag the google-services.json file that you just downloaded to the app folder (within the app), as show here by the red highlight:

You’ll get a dialog asking if you want to move the downloaded one to the app folder. Say ‘OK’. You’ll get a few more confirm dialogs. Accept them.

Now do a Gradle Sync, and the problem will have gone away! 🙂