Reputation: 10395
Recently, i had to updated crashlytic dependency which requires firebase core dependency. this leads to a strange remote config failure on devices without google play services support (Huawei devices and emulators).
Exception happens when i try to fetch remote config values :
await remoteConfig.fetch(expiration: const Duration(hours: x));
Exception: Unable to complete fetch. Reason is unknown but this could be due to lack of connectivity.
when i revert back changes for firebase_core initialisation, that line goes through and remote config successfully fetched.
tried updated all related dependencies to the latest versions with no success:
firebase_core: ^0.5.0+1
firebase_remote_config: ^0.4.0+2
regarding to this post and documentation remote config should not depend on google play services and it should fetch without any problem , also as in some other threads mentioned about restricted api key i did not restrict firebase api key. any help and insight would be highly appreciated.
Upvotes: 0
Views: 2791
Reputation: 76536
Huawei devices run without Google Mobile Services (https://www.android.com/intl/en_uk/gms/) this means they don't have Google Play Services, some Firebase libraries depend on these and some don't, but because Firebase Remote Config is not open source, you can't know if it is using now or if it will in the future.
Your best bet would be to create an abstraction for yourself around Firebase Remote Config. Think of it as "Your App Remote Config". You can have an interface YourAppRemoteConfig
that you implement to use Firebase
, then when you either detect an error or you detect you are running on a Huawei device, you can implement another version of your interface using Huawei
Remote Configuration.
Huawei Remote Configuration is as easy to use as Firebase Remote Config.
Add the dependencies:
implementation 'com.huawei.agconnect:agconnect-core:1.5.2.300'
implementation 'com.huawei.agconnect:agconnect-remoteconfig:1.5.2.300'
implementation 'com.huawei.hms:hianalytics:6.0.0.300'
And fetch, just like your question does with Remote Config:
config = AGConnectConfig.getInstance()
config.fetch(0) // a value of 0 here is for DEBUGGING ONLY, delete for prod (giving a 12 hour refresh period)
.addOnSuccessListener {
config.apply(it)
Log.d(TAG, "Applied")
//update based on RemoteConfig
}
Reference: https://blog.blundellapps.co.uk/remote-configuration-using-appgallery-connect/
Upvotes: 2
Reputation: 2035
Firebase Remote config: Firebase did not rely on GMS at the beginning, but later versions used AAID of GMS, which led to dependency for GMS, but the new version in the 2nd half of this year cancelled the dependency on GMS, so currently the latest version does not depend on GMS.
Firebase Crashlytics: Depend on GMS. (tested on Huawei Mate 30 which doesn’t have GMS) The crash log and crash information can be uploaded, but because there is no GMS, it is impossible to count the crash rate and other information. Tested on Huawei Mate30 mobile phone(No Google GMS service), the crash log and related log events can be obtained, but there is no information such as the crash rate.
Upvotes: 1