Marco Zanetti Marco Zanetti - 1 year ago 289
Android Question

Missing api_key/current key with Google Services 3.0.0 and Maps API key in build.gradle

my issue is quite similar to Missing api_key/current key with Google Services 3.0.0 but with a further level of complexity.

I updated my app this morning to and all the play-services 9.0.0 dependencies

compile ''
compile ''
compile ''
compile ''

Now I get the infamous error

Error:Execution failed for task ':hotelsclick:processDebugGoogleServices'. > Missing api_key/current_key object

This seems to be due to a missing API key in the google-services.json file (so I was told). I got a new API key from and found the following field in it.

"api_key": [],

I guess I should put my Google Maps API key in there, but here it comes the double issue I'm experiencing:

1- if I try and put the key inside that field, it doesn't work. I tried with both

"api_key": [{ "current_key": "AIzaSyBll61Ij0Swz1mbGz4rZzxquSacbHIt-AE" }],


"api_key": ["AIzaSyBll61Ij0Swz1mbGz4rZzxquSacbHIt-AE"],

the error remains the same.

2- I've been using gradle in order to use dynamic building. I put the following in my module build.gradle:

buildTypes {
release {
minifyEnabled true
shrinkResources true
debuggable false
resValue "string", "google_maps_api_key", "ABCDEFGHILMNO... my maps release API key"
proguardFiles getDefaultProguardFile('proguard-android.txt'),
zipAlignEnabled true
debug {
resValue "string", "google_maps_api_key", "ZNTMRNCDNR... my google maps debug API key"
debuggable true
proguardFiles getDefaultProguardFile('proguard-android.txt'),

In the Androidmanifest.xml file I have

android:value="@string/google_maps_api_key" />

Now, it's always been working until I updated to Google Services 3.0.0, I don't get why it doesn't work now. Shouldn't it grab the right API key from the compiled build.gradle file and put it in the manifest?

So my double question is: why doesn't the dynamic API key fetching work anymore? And how can I fix this?

Thank you

Answer Source

Have you tried putting an empty "current_key" as follows:

"api_key": [{ "current_key": "" }]

See how that goes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download