Firebase is not integrated properly in my Flutter android release builds - android

Firebase authentication with google signin is getting crashed in my release build app in playstore, however its working fine in local.
I had already added release signing keys, app signing from play console in firebase console and all class libraries in my build.gradle file(firebase-auth,proguard rules, firestore), still I am seeing this exception
Fatal Exception: java.lang.RuntimeException: Internal error in Cloud Firestore (24.0.1).
at com.google.firebase.firestore.w0.x.b(:19)
at com.google.firebase.firestore.w0.f.run(:2)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7697)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
in firebase Crashlytics. I will also add the build.gradle files. Could anyone pls help me?
I tried some of the suggestions from stackoverflow and other forums, but no luck.
1)pubspec.yaml
2)
3)build.gradle

Follow this documentation
https://docs.flutter.dev/deployment/android#publishing-to-the-google-play-store
make sure you have all the permissions in res/AndroidManifest (not the debug/AndroidManifest). res/AndroidManifest is used for production!

Related

'Package signed with unknown certificate' while trying to call 'play-services-pay' Android SDK API

I am trying to implement feature to add Loyalty Card into Google Pay account from my React Native application. I am using this tutorial.
I successfully created custom Native package and module and my calls from JavaScript are working. Thats not my problem.
My problem is when I am calling Pay.getClient(this.getCurrentActivity());. I get this error:
2021-07-29 21:38:40.695 17480-19373/com.examp.le E/GoogleApiManager: Failed to get service from broker.
java.lang.SecurityException: GoogleCertificatesRslt: Package signed with unknown certificate (go/gsrlt)
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at com.google.android.gms.common.internal.IGmsServiceBroker$Stub$zza.getService(com.google.android.gms:play-services-basement##17.5.0:14)
at com.google.android.gms.common.internal.BaseGmsClient.getRemoteService(com.google.android.gms:play-services-basement##17.5.0:281)
at com.google.android.gms.common.api.internal.zabj.run(com.google.android.gms:play-services-base##17.5.0:11)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.os.HandlerThread.run(HandlerThread.java:67)
Seems like this means that I cannot initialize/get GoogleApi access, because I am in debug mode (building my application in debug mode) and my certificate is not signed.
I found just very limited documentatin for com.google.android.gms:play-services-pay package so I am not sure if I am even able to call this in debug/development environment.
Any idea how to make it work? Can it be caused by my Activity originating from React Native (ReactContextBaseJavaModule.getCurrentActivity())?
EDIT: Same error also on Release version with Google's keystore :(

Firebase not working com.google.firebase.installations.FirebaseInstallationsException

I am working on an Android app, I was in a situation that I want to move the app to a new firebase project, so I removed the old firebase project and created a new one, then I added my app to that project. After that, no firebase functionalities are working.
I have firebase cloud messaging in my app, it was working but it's not working now, I am not receiving FirebaseMessagingService$onNewTokenand also I am using firestore as my back-end database. Inside my .addOnSuccessListener I am getting 0 documents back. It's not failing but returning no documents.
I thought might be a problem with firebase, so I created a test app in node.js and I try to fetch documents from firestore it's working fine.
The android app is not crashing, but checked the error log, and I am seeing the following log.
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException
at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
at com.google.firebase.iid.zzs.zzb(com.google.firebase:firebase-iid##20.1.1:54)
at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid##20.1.1:89)
at com.google.firebase.iid.zzv.run(Unknown Source:12)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.google.firebase.installations.FirebaseInstallationsException
at com.google.firebase.installations.FirebaseInstallations.doRegistrationInternal(com.google.firebase:firebase-installations##16.0.0:333)
at com.google.firebase.installations.FirebaseInstallations.doGetId(com.google.firebase:firebase-installations##16.0.0:280)
at com.google.firebase.installations.FirebaseInstallations.access$lambda$0(Unknown Source:0)
at com.google.firebase.installations.FirebaseInstallations$$Lambda$1.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:764) 
2020-03-05 21:18:49.022 23658-23666/app.spidy.cyberwire E/spidy.cyberwir: Something went wrong getting fds from adb. Retry!: Success
2020-03-05 21:20:11.198 23658-24183/app.spidy.cyberwire E/FirebaseInstanceId: Failed to get FIS auth token
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException
at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
at com.google.firebase.iid.zzs.zzb(com.google.firebase:firebase-iid##20.1.1:54)
at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid##20.1.1:89)
at com.google.firebase.iid.zzv.run(Unknown Source:12)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.google.firebase.installations.FirebaseInstallationsException
at com.google.firebase.installations.FirebaseInstallations.doRegistrationInternal(com.google.firebase:firebase-installations##16.0.0:333)
at com.google.firebase.installations.FirebaseInstallations.doGetId(com.google.firebase:firebase-installations##16.0.0:280)
at com.google.firebase.installations.FirebaseInstallations.access$lambda$0(Unknown Source:0)
at com.google.firebase.installations.FirebaseInstallations$$Lambda$1.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:764) 
2020-03-05 21:22:41.287 23658-24278/app.spidy.cyberwire E/FirebaseInstanceId: Failed to get FIS auth token
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException
at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
at com.google.firebase.iid.zzs.zzb(com.google.firebase:firebase-iid##20.1.1:54)
at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid##20.1.1:89)
at com.google.firebase.iid.zzv.run(Unknown Source:12)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.google.firebase.installations.FirebaseInstallationsException
at com.google.firebase.installations.FirebaseInstallations.doRegistrationInternal(com.google.firebase:firebase-installations##16.0.0:333)
at com.google.firebase.installations.FirebaseInstallations.doGetId(com.google.firebase:firebase-installations##16.0.0:280)
at com.google.firebase.installations.FirebaseInstallations.access$lambda$0(Unknown Source:0)
at com.google.firebase.installations.FirebaseInstallations$$Lambda$1.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:764) 
2020-03-05 21:27:11.330 23658-24399/app.spidy.cyberwire E/FirebaseInstanceId: Failed to get FIS auth token
java.util.concurrent.ExecutionException: com.google.firebase.installations.FirebaseInstallationsException
at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
at com.google.firebase.iid.zzs.zzb(com.google.firebase:firebase-iid##20.1.1:54)
at com.google.firebase.iid.zzs.zza(com.google.firebase:firebase-iid##20.1.1:89)
at com.google.firebase.iid.zzv.run(Unknown Source:12)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.google.firebase.installations.FirebaseInstallationsException
at com.google.firebase.installations.FirebaseInstallations.doRegistrationInternal(com.google.firebase:firebase-installations##16.0.0:333)
at com.google.firebase.installations.FirebaseInstallations.doGetId(com.google.firebase:firebase-installations##16.0.0:280)
at com.google.firebase.installations.FirebaseInstallations.access$lambda$0(Unknown Source:0)
at com.google.firebase.installations.FirebaseInstallations$$Lambda$1.run(Unknown Source:2)
If you have recently change your google-services.json file then just delete build folder from android project and re-build your project.
I had the same problem because access to internet (wifi and mobile) was disabled
I had the same problem (Failed to get FIS auth token) with firebase-messaging version 20.1.1 and 20.1.2. I've solved it by downgrading to 20.1.0.
It looks like Firebase team has some problems with these versions according to Release Notes:
Warning: The following two library versions released with this update have known issues and should not be used: firebase-messaging v20.1.1 and firebase-iid v20.1.0.
Firebase Android SDK updates on February 27 (M65) and afterwards introduced a new infrastructure service, the Firebase Installations SDK which comes with a dependency on the Firebase Installations API.
Firebase Installations requires valid Firebase options API key, project ID, and application ID (a.k.a. "appId") in order to successfully communicate with Firebase servers.
Errors during communication with the Firebase Installations API indicate invalid Firebase options or misconfigurations regarding API keys.
To mitigate the issue
make sure that your application is using valid Firebase options from the latest google-services.json file from your Firebase console:
Firebase options: instructions and background.
If you use API restrictions, make sure that the API key used by your application is white-listed for the Firebase Installations API (and for your application):
API restrictions: instructions and background
Regarding Application restrictions: Either set the radio button to None or make sure that your app is white-listed (with the correct SHA-1 certificate).
For details, please visit:
https://firebase.google.com/support/privacy/init-options
I had the same issue and in my case, my android emulator didn't have Google Play Services added. Created a new one with Google Play Services services and it worked.
Instead of downgrading, enable Firebase Installation API to your firebase key from
Firebase: 403 PERMISSION_DENIED (FirebaseError: Installations): Requests are blocked, after updating SDKs (FirebaseInstallationsService)
Solution 1
If you made any configuration changes in the firebase console - Redownload and update google-services.json file in the project.
Solution 2
If You are using a Real device Check your Internet connection.
If you are using android studio Emulator - Establish an internet connection by resetting the emulator.
2.1. Open Tools -> AVD manager
2.2. Wipe Data of the emulator
Run Project using fresh emulator.
just delete the google-services.json file form the project ,clean project, after that rebuild the project
There could be multiple reasons for the above error. The one which I have faced is due to SHA-1 certificate fingerprint restrictions.
Was facing the above issue for the Android in the store build due to restrictions.
Steps to avoid this error.
Add your SHA-1 certificate fingerprint to the firebase project setup
Also add the same SHA-1 certificate fingerprint in Google Cloud Console.
Steps to add SHA-1 certificate fingerprint to Google Cloud Console:
Open Google Cloud Console & Select your project
Click API`s & Services Tab
Then Select Creditionals
Then go API Section
And Finally, check your SHA-1 Key is added on Restrict usage to your Android apps section or not. If not add it with the package name and SHA-1 Key.
I had the same issue and in my case, so i run two commands "flutter clean" and then "flutter pub get" and it works for me.
I tried all the solutions. Nothing worked. Ultimately I had to delete the Application from the Firebase project, re-create it and add the newly generated google-services.json.
While at it, I also changed the Firebase-flutter dependencies to
firebase_core: ^1.5.0
firebase_messaging: ^10.0.5
And android dependencies to
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:28.3.1')
implementation "com.google.firebase:firebase-messaging:21.0.1"
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.android.support:multidex:1.0.3'
My issue had started after I added the SHA-1 code after setting up the application.
I encountered this on my Flutter app but none of the solutions I found online works. After a dozen hair-pulling hours, what works for me is to run it in release mode via.
flutter build apk
and install it via adb
adb install project/build/app/outputs/flutter-apk/app-release.apk
Replace google-services.json file
Delete project in Firebase console & re-create again
Deleting Generated & Build files
Flutter clean
Non of above worked for me.
I had to change the application id & re-created firebase app again
We also encountered the same issue, while checking the google-services.json file, we found two entries of same key "api_key" .. removing the duplicate entry got the project working.
(Maybe it was due to corrupted json file download from console, which might be solved if downloaded again, as mentioned in the previous answers)
Make sure that your date and time on emulator are correct. It fixes the issue for me.

Facebook login through FirebaseAuth UI fails

I've set up the Firebase Auth UI API in my Android project and Google signin works perfectly, but facebook login always fails, even though I set it up in developers.facebook.com. The error is presented below
E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Developer error
at com.firebase.ui.auth.util.data.ProviderUtils$1.then(ProviderUtils.java:219)
at com.firebase.ui.auth.util.data.ProviderUtils$1.then(ProviderUtils.java:195)
at com.google.android.gms.tasks.zzf.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:768)
Anyone knows what this is due to? The error is not at least a bit enlightening...
If you are using FirebaseUI, you must put this exact string in strings.xml:
APPID
The APPID can be found on your developers.facebook.com dashboard.
See Firebase auth readme
Also be sure to add your android key hash and OAuth firebase URL in the facebook app.

Unusual Firebase Google Sign-In Behavior

I've been working on an Android project recently which required me to implement Google Sign-In feature in one the activity using Firebase. There's this unusual problem that I'm facing:
Whenever I build the program on my Android phone the google sign-in works fine. Enabling me to sign in easily.
(I commit my code to Github)
Now when my mentor fetches the updated code from GitHub and builds the project on his phone, the Google Sign-In does not work i.e. he's unable to log in.
He gets the following error:
E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Code: 12500, message: 12500:
at com.firebase.ui.auth.data.remote.GoogleSignInHandler.onActivityResult(GoogleSignInHandler.java:109)
at com.firebase.ui.auth.ui.idp.SingleSignInActivity.onActivityResult(SingleSignInActivity.java:128)
at android.app.Activity.dispatchActivityResult(Activity.java:7317)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4436)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4484)
at android.app.ActivityThread.-wrap19(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1743)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6753)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
However, when I send him the APK build on my system it works fine on his device.
What could be the possible reason for this and how do I solve this problem?

Cannot find GOOGLE appId for project : <projectid>

I'm implementing google authentication on firebase using the firebaseui lib.
Firebase is working properly, i can access the data in my database, and email/password auth is also working, although when i try to login using google i always get the same error :
W/AuthMethodPicker: Firebase sign in with credential unsuccessful
com.google.firebase.FirebaseException: An internal error has occured. [ Cannot find GOOGLE appId for project: 12345678. ]
at com.google.android.gms.internal.zzafg.zzes(Unknown Source)
at com.google.android.gms.internal.zzafd$zzg.zza(Unknown Source)
at com.google.android.gms.internal.zzafo.zzet(Unknown Source)
at com.google.android.gms.internal.zzafo$zza.onFailure(Unknown Source)
at com.google.android.gms.internal.zzafj$zza.onTransact(Unknown Source)
at android.os.Binder.execTransact(Binder.java:453)
i know that this value is extracted from the json file and added as a resource property during build by com.google.gms.google-services plugin, so i checked and the property was in fact added but for some reason it seems that firebase is not able to read it at runtime..
Any idea about what i can be doing wrong?
thanks!
Before you generated your app's google-services.json, did you enable Google Sign In for your project?
https://developers.google.com/identity/sign-in/android/start-integrating
Make sure you have a Firebase project
In that project make sure you have enabled GOOGLE AUTHENTICATION
Now Download a fresh copy of the google-services.json and replace it with the old one inside your app folder
yes i enabled google auth before generating the json.
Another detail is descovered in the meantime if that google auth does work without firebase-ui.
What i did was to try their example of google auth (adding to my app source) and it worked without issues.
Adding firebase-ui seems to remove the need for some extra logic so i wanted to use it, but it seems i'm either missing something or there is a bug on firebase-ui .
Leaving this here for anyone that might encounter this issue now.
Had a similar problem to above only difference is i had it on iOS. Would try to launch and sign in through google and would get the same internal error.
What worked for me was enabling the identity kit on google API and then checking "Google" and the other providers I used. You can find this on the google cloud console -> API Manager -> Dashboard.
App restart, clean build and then everything worked.

Categories

Resources