question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remote Config fetch fails below API 19 (Kitkat)

See original GitHub issue

Describe your environment

  • Android Studio version: 3.5.1
  • Firebase Component: Remote Config (Database, Firestore, Storage, Functions, etc)
  • Component version: 19.0.3
  • Issue found on: API 17 (Below Kitkat)

Describe the problem

Firebase remote config fails to fetch config values on API level below 19. Exception thrown is FirebaseRemoteConfigServerException: Bad Request.

Steps to reproduce:

Run the official sample code - https://github.com/firebase/quickstart-android/tree/master/config on any API 17 emulator. Click on ‘Run the java version …’

  • What happened Fetch fails and the exception thrown is com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException with message - Bad request.

Complete trace -

    com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException: Fetch failed: The server returned an unexpected error.
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.createExceptionWithGenericMessage(com.google.firebase:firebase-config@@19.0.3:351)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackend(com.google.firebase:firebase-config@@19.0.3:304)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackendAndCacheResponse(com.google.firebase:firebase-config@@19.0.3:251)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchIfCacheExpiredAndNotThrottled(com.google.firebase:firebase-config@@19.0.3:191)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.lambda$fetch$0(com.google.firebase:firebase-config@@19.0.3:160)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$Lambda$1.then(com.google.firebase:firebase-config@@19.0.3)
        at com.google.android.gms.tasks.zzf.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
        at java.lang.Thread.run(Thread.java:841)
     Caused by: com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException: Bad Request
        at com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient.fetch(com.google.firebase:firebase-config@@19.0.3:189)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackend(com.google.firebase:firebase-config@@19.0.3:278)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackendAndCacheResponse(com.google.firebase:firebase-config@@19.0.3:251) 
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchIfCacheExpiredAndNotThrottled(com.google.firebase:firebase-config@@19.0.3:191) 
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.lambda$fetch$0(com.google.firebase:firebase-config@@19.0.3:160) 
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$Lambda$1.then(com.google.firebase:firebase-config@@19.0.3) 
        at com.google.android.gms.tasks.zzf.run(Unknown Source) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 

Upon further inspection, looks like the analyticsUserProperties user property is wrongly formatted in the request body. on API 17 -

{
	"platformVersion": "17",
	"languageCode": "en_GB",
	"analyticsUserProperties": "{}",
	"appId": "[REDACTED]",
	"packageName": "com.google.firebase.quickstart.invites",
	"appVersion": "1.0",
	"appInstanceId": "REDACTED",
	"appInstanceIdToken": "REDACTED",
	"countryCode": "GB",
	"timeZone": "Asia\/Calcutta",
	"sdkVersion": "19.0.3"
}

Response -

{
	"error": {
		"code": 400,
		"message": "Invalid value at 'analytics_user_properties' (type.googleapis.com/google.firebase.remoteconfig.v1.FetchRemoteConfigRequest.AnalyticsUserPropertiesEntry), \"{}\"",
		"status": "INVALID_ARGUMENT",
		"details": [{
			"@type": "type.googleapis.com/google.rpc.BadRequest",
			"fieldViolations": [{
				"field": "analytics_user_properties",
				"description": "Invalid value at 'analytics_user_properties' (type.googleapis.com/google.firebase.remoteconfig.v1.FetchRemoteConfigRequest.AnalyticsUserPropertiesEntry), \"{}\""
			}]
		}]
	}
}

on API 21 -

{
	"platformVersion": "17",
	"languageCode": "en_GB",
	"analyticsUserProperties": {},
	"appId": "[REDACTED]",
	"packageName": "com.google.firebase.quickstart.invites",
	"appVersion": "1.0",
	"appInstanceId": "REDACTED",
	"appInstanceIdToken": "REDACTED",
	"countryCode": "GB",
	"timeZone": "Asia\/Calcutta",
	"sdkVersion": "19.0.3"
}

If JSONObject().toString() is done on a nested map objects it produces "{}" instead of just {}, on API(17). If someone could explain this that would be doubly helpful, thanks.

Between, on remote config version 18.0.0 it works fine.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
clp93commented, Dec 10, 2019

Hey @Protino, RC SDK Version 19.0.4 should have the fix you’re looking for.

We’ve verified that the regression was not observed on our test devices running API 18 with the new SDK, and as such, I’ll mark the issue as closed.

Thanks for the report!

0reactions
Protinocommented, Nov 21, 2019

@clp93 Thanks. Not immediately required as of now, will continue to use 18.0.0. Will close the issue once a fix is available in production.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get started with Firebase Remote Config - Google
If an app fetches too many times in a short time period, fetch calls are throttled and the SDK returns FIRRemoteConfigFetchStatusThrottled . Before...
Read more >
Using Google Firebase Remote Config without Google Play ...
0] seems to be working on devices with no Google PlayServices. I'm using it with Firebase analytics [17.4.
Read more >
Release Notes - Play services - Google Developers
PendingIntent based APIs invoked by instant apps will now correctly fail ... Remote Config; Firebase installations; Firebase SDK for Google Analytics.
Read more >
AudioManager - Android Developers
An error code indicating that the object reporting it is no longer valid and needs ... Get the audio devices that would be...
Read more >
Android version history - Wikipedia
The version history of the Android mobile operating system began with the public release of the Android beta on November 5, 2007.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found