Flutterfire: Exception: Unable to fetch remote config

Created on 6 Dec 2019  路  17Comments  路  Source: FirebaseExtended/flutterfire

firebase_remote_config plugin:
I am running, from a device, the example code from the github page: link
But I receive the error "Exception: Unable to fetch remote config" even if I set debugmode false with expiration 5 h.

To Reproduce
Steps to reproduce the behavior:

  1. Go to the example page link
  2. run the example

Expected behavior
I expect it to get the value from the remote configuration

crowd bug

Most helpful comment

@iapicca I created a PR https://github.com/FirebaseExtended/flutterfire/pull/1999 to handle different types of exception. I think this will help more to identify exception.

All 17 comments

Hi @dekadevelop
does the solution proposed by @pro100svitlo
solve the issue?
thank you

I think this issue has appeared to my production app (I log errors to Crashlytics and this is now top 1 error). I am quite sure I have not made related changes lately (except possibly updated Remove Config plugin) and it worked before.

Hi @kinex
does the proposed solution works for you?
thank you

I have the same issue:
Non-fatal Exception: java.lang.Exception: Exception: Unable to fetch remote config
at RemoteConfig.fetch(remote_config.dart:134)

"Create a new google-services.json" is quite confusing "solution". I would like to know the actual reason for the issue. Why a previously working "google-services.json" would cause the issue now.

Anyway, I did try downloading a "google-services.json" again. Luckily I tried it with my development project and not with the production project, because this is what happened:

  1. Firebase console created a new API key. Why?
  2. The old API key was blocked. I was not able to sign in anymore until I updated the "google-services.json" to my app and rebuilt it. Sign in worked 5 minutes earlier with the old API key when I had not downloaded the new "google-services.json" yet.

So I thought I was just downloading the latest "google-services.json" file but Firebase console decided to create a new API key and block the old API key without any warning. This would have been a disaster if it had happened in my production app. So I am not going to try it there. I have already contacted Firebase support but they don't seem to have any explanation why this happened at least not so far.

I have not actually tested very well did this new API key fix the issue with the "Remote Config". Even if it fixed it I cannot do this anyway in my production app.

I have the same issue always failed to get remote config. always..

@kinex

I think this issue has appeared to my production app (I log errors to Crashlytics and this is now top 1 error). I am quite sure I have not made related changes lately (except possibly updated Remove Config plugin) and it worked before.

I wonder if the certificate fingerprint settings is lack.
If you use certificate fingerprint which is different from local build, you face this issue.
I recommend checking Google Play Console > Release management > App signing, and compare with that of local build.

hope it helps

@sensuikan1973 Thanks for the idea, but if there was some issue with the certificate fingerprint then nothing in my app should work (sign in with Google, Firestore etc.), but those are working properly.

I also released iOS app recently and there seems to be same exception in iOS.

In my case what helped was making sure remote config related code was called once at app init, not in multiple widgets multiple times

@iapicca I created a PR https://github.com/FirebaseExtended/flutterfire/pull/1999 to handle different types of exception. I think this will help more to identify exception.

Sorry for the late answer, but updating the google-service.json did not solve the issue for me.. I'll try other solutions

It happens when trying to fetch the configurations:

final Map properties = await channel.invokeMapMethod('RemoteConfig#fetch',{'expiration': expiration.inSeconds});

The exception message is:
"Unable to complete fetch. Reason is unknown but this could be due to lack of connectivity."

@iapicca I created a PR #1999 to handle different types of exception. I think this will help more to identify exception.

How can I use the version of your PR in my code? Thank you

I found out the issue guys. My Firebase API key was restricted to some APIs and the remote config was not included. Once I included it, I could fetch the configs.

Hi @dekadevelop
I'm glad that you solved the issue
thank you for letting me know

For those who stumbled upon this discussion later - here is how you can check if your Key was restricted: https://stackoverflow.com/a/62039829/5502121

Was this page helpful?
0 / 5 - 0 ratings