Firebase Authentication fails with FirebaseException: Instantiation of JsonResponse failed - android

Problem
I have just created an update for one of my Xamarin.Forms apps and now I have the problem that the Firebase sign-in workflow is suddenly broken after uploading the new .aab to Google Play. It has been working fine until now.
When I attempt to sign-in, the following error message appears in the device log after selecting the Google user account:
Time Device Name Type PID Tag Message
11-18 16:49:57.295 Samsung SM-S901B Verbose 5646 mono-stdout com.google.firebase.FirebaseException: An internal error has occurred. [ Instantiation of JsonResponse failed! class com.google.android.gms.internal.firebase-auth-api.zzaac ]
at com.google.android.gms.internal.firebase-auth-api.zzwe.zza(com.google.firebase:firebase-auth##21.0.8:4)
at com.google.android.gms.internal.firebase-auth-api.zzxc.zza(com.google.firebase:firebase-auth##21.0.8:9)
at com.google.android.gms.internal.firebase-auth-api.zzxd.zzl(com.google.firebase:firebase-auth##21.0.8:1)
at com.google.android.gms.internal.firebase-auth-api.zzxa.zzh(com.google.firebase:firebase-auth##21.0.8:25)
at com.google.android.gms.internal.firebase-auth-api.zzwc.zzh(com.google.firebase:firebase-auth##21.0.8:1)
at com.google.android.gms.internal.firebase-auth-api.zzua.zza(com.google.firebase:firebase-auth##21.0.8:2)
at com.google.android.gms.internal.firebase-auth-api.zzxl.zzb(com.google.firebase:firebase-auth##21.0.8:13)
at com.google.android.gms.internal.firebase-auth-api.zzxl.zza(com.google.firebase:firebase-auth##21.0.8:14)
at com.google.android.gms.internal.firebase-auth-api.zzwr.zzq(com.google.firebase:firebase-auth##21.0.8:4)
at com.google.android.gms.internal.firebase-auth-api.zzuh.zzA(com.google.firebase:firebase-auth##21.0.8:4)
at com.google.android.gms.internal.firebase-auth-api.zzwd.zzu(com.google.firebase:firebase-auth##21.0.8:5)
at com.google.android.gms.internal.firebase-auth-api.zzvj.zzc(com.google.firebase:firebase-auth##21.0.8:1)
at com.google.android.gms.internal.firebase-auth-api.zzxe.run(com.google.firebase:firebase-auth##21.0.8:1)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
This only affects the Release build which is signed by Google Play and therefore, I cannot replicate this in the debugger. When running the debug version, everything works as expected.
Additional Info
Android Version: 13.0
Android Target API: 33
NuGet Packages (only seemingly relevant ones shown):
Xamarin.Forms 5.0.0.2515
Google.Apis 1.57.0
Google.Apis.Auth 1.57.0
Xamarin.Firebase.Auth 121.0.8
Xamarin.Firebase.Common 120.1.2
Xamarin.GooglePlayServices.Auth 120.3.0
I am using the Google Sign-In button in my Android activity and I am not using the Web Authenticator (yet).
I use Android App Bundles (.aab) for publishing instead of uploading .apk files.
What I've tried so far
I have checked all SHA certificate fingerprints (for Debug and Release builds as well as the signing certificate in my keystore and the one used by Google Play to sign the release) against the ones in the Firebase Console, google-services.json, Google Cloud Console and also the application restrictions for my Android API key.
Debugging does not yield the same outcome, so I've only managed to use the device log to get to the exception shown above.
Apart from that, I have upgraded to the latest versions of the Google and Firebase Auth libraries for Xamarin.Forms.
I'm a bit at a loss now. Does anyone have any suggestions on how to narrow this further down or has anyone experienced this problem before?

It works again.
The issue was unrelated to the signing certificates (which is usually the first go-to for these kind of problems) and the libraries that are being used.
This problem was actually caused by a small optimization which was causing the code shrinker to remove some Firebase related code. Disabling the code shrinker (temporarily) solved the issue.

Related

Why after generating a signed APK release do I still receive INSTALL_PARSE_FAILED_NO_CERTIFICATES during development?

My Problem:
I'm still receiving the INSTALL_PARSE_FAILED_NO_CERTIFICATES error after creating the necessary keystore, key and signing my application. This error initially occurred after updating the minSdkVersion version to 24 for needed functionality, but it still occurs after completing the resolution. I'm not sure why exactly.
What I have done:
I have followed the wizard procedures (see links below) for creating a signed release of my app currently in development, creating the keystore, key, password, signing the app, etc, etc. I've read a number of posts here but nothing appears to address my issue specifically - that I have found so far. Only how resolve the initial reason for the error -- not having a signed app.
What haven't I done is the Google Play app signing. I didn't think this was necessary until I'm ready to move the app there and I may not actually ever offer it there.
Any thoughts or help would be appreciated as my app development is now dead in the water until I resolve this issue.
I followed all the steps here:
https://developer.android.com/studio/publish/app-signing - Steps 1 and 2 specific to signing your app.
https://www.jetbrains.com/help/idea/extracting-a-signed-android-package.html
I solved my problem. My emulator device version was not compatible. Once I setup a new emulator device meeting the minimum version, the app began to install successfully. So increasing the minSdkVersion caused my emulator device to be incompatible.

getToken() failed. Status BAD_AUTHENTICATION error

I've found the following error when running my android application in android studio. app couldn't get installed on my device because of this error. Didn't find the solution :(
please help
Auth: [GoogleAccountDataServiceImpl] getToken() failed.
Status BAD_AUTHENTICATION,
Account: ,
App:com.android.vending,
Service: androidmarket com.google.android.gms.auth.be.account.b.d: Long live credential not
available.
I had the same issue what helped me was that I had wrong credentials in my google-services.json file and after getting a new file my problem was fixed.
in the process of resolving this issue I also updated my google play services but I do not think this is necessary .
I got this error when tried to install app directly from Android Studio.
It was due to certificate mismatch, since I used release certificate for setting up the app in Play Console, while Android Studio signs the app with debug certificate by default.
Installing app via adb resolved the error.
https://developers.google.com/games/services/android/quickstart#step_4_test_your_game
Make sure to run an APK that you exported and signed with a
certificate that matches one of the certificates you used during the
application setup in Google Play Console.
I have the same problem some days ago. I just compile my whole code in a new project and Problem Solved!!.
Don't know what was the real problem. There is an issue filed here, with no solution.
There are several reasons you can get that message:
The account you are trying to log on with needs to be re-authenticated on the phone (try a different account)
The gms:play-services version is out of date (needs to be 15+ as of Jan 2021)
Your app fingerprint is not the right one. You need one for dev builds, different one for prod -- which is different based on how you sign (do you have the final publish key, or does Play store re-sign with the final publish key?)
Follow the Google tutorial and get their stand-alone project, it should take 20 min, and check your setup there. If you are running it with all the right accounts it should work. Then go back to your app.
https://developers.google.com/identity/sign-in/android/start
I updated Google Play Services on my phone and stopped receiving the same error. I am importing com.google.android.gms:play-services-cast:9.6.1 and analytics:9.6.1. Not sure if the version running on the device was too low but problem is now resolved but not sure how to prevent this error for users running older versions of Google Play Services.
Tested the other solutions but nothing worked. Rebooted the device and error was gone.
If you using firebase server, As per the firebase updation if you give phone number authentication put your country code before contact number it is mendetory.
example - +91 9999998888
This happened to me, auth errors in ADB, among them:
android Warn Auth [GoogleAuthUtil] GoogleAuthUtil
Because, like mentioned above, I had a debug build running on phone previously. So I fully uninstalled the app on my phone, and the next [Build and Run] ran successfully.
Please try the App with new google credentials or even try creating the whole peoject on console og google play services if you have used it .
In my case it was a dependency version problem. I had to update the auth dependency for firebase to the latest one:
implementation 'com.google.firebase:firebase-auth:17.0.0'
Here is my take towards this problem:
You may be using a single email to try and log in to google. It may be possible you might have changed the password of the particular email in the recent past. Make sure u remove your google-email from your phone/emulator. When u re-run your application, you will be asked to enter both email and password credentials.
Check if your credentials.json is still valid. Sometimes its possible that your client ID might be removed/corrupted if you have not used your android application for a long time. Make a new one and dont forget to copy-paste it in app folder of Android Project view.
PS: I am new to Android Studio and writing answers on stackoverflow in general. If you are reading this comment please let me know what improvements i can make while answering questions in the future.
I copied and ran the code in a different project that had priorly worked on simple DB operations of Firebase. Probably it already had the authentication files in place so launching the app was solved there
Mostly your token has gone bad. And needs a new one.
Go to project database > settings > General > download Json file and replace it with the one in the local project directory.
I fixed this problem with updating fingerprints (sha1 or sha256)
My problem was with Microsoft App Center.
We recently set our pipelines to send aab files to App Center, instead of apk files.
It seems that our bundle was resigned by App Center with some generated keystore. That's how App Center distributed apk files, even though our pipeline uploaded aab files.
In other words: even though our pipeline is using our own keystore to sign the aab bundle, in order to distribute through the App Center, after sending the aab to App Center, the App Center is creating universal apks with another generated keystore.
After rolling back our pipeline to send apk instead of aab, Google SignIn on our react-native app with firebase was working again.
"When you distribute Android Application Bundle (AAB), App Center generates a universal APK, signs it with a generated signing key, and distributes it to a device."
Source: https://learn.microsoft.com/en-us/appcenter/distribution/uploading

Xamarin Debug Keystore Seems to have Changed

I am developing an Android Application using Xamarin.Android in Xamarin Studio. It uses Google Play Game Services.
The project has run and tested find up until this point. Yesterday I upgraded my development PC from Windows 7 to Windows 8.1. In the process I also had to reinstall Xamarin Studio.
Now when my app attempts to connect to Google Play, it fails with error "RESULT_APP_MISCONFIGURED" which as far as I can tell means that my app is not properly authorized to access the Google Play API. However, nothing has actually changed.
I tested an older version of the app, and it is still able to connect to the Google Play API. Nothing in the code itself has changed, so I think it must be something to do with my recently upgrade of Windows, or the recent re-install of Xamarin Studio.
Any thoughts on what would help narrow down the problem? Is it possible the debug keystore has changed somehow?
An additional clue: when I attempt to build an deploy to a device that has the older, working version of the app on it, I get the following error:
Deployment failed because of an internal error: Failure
[INSTALL_FAILED_UPDATE_INCOMPATIBLE]
I then have to manually uninstall the old version before the new one can be deployed.
As has already been pointed out, the debug keystore won't be the same on all installations of Xamarin.Android. Which is expected behavior.
When using Play Services you want to create a keystore, preferably one for debug and one for release, or as different aliases in the same keystore (you figure that out).
Then you can make the build process automagically sign your app by adding some stuff to your .csproj file. You can read more about this in the docs.
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>public.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>MyKeystorePassword</AndroidSigningStorePass>
<AndroidSigningKeyAlias>MyKey</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>MyKeyPassword</AndroidSigningKeyPass>
</PropertyGroup>
You can make a similar block for Debug as well choosing either another alias or another keystore.
Yes, debug keystore is part of the Xamarin installation and it changes if you reinstall Xamarin. You need to update the key signature on Google console, this time create a keystore and keep it hidden, keep it safe (so to speak).

ProGuard meets Drive API

My app works pretty good without ProGuard but when using it, I always get
403 UsageLimits, Access Not Configured
errors from the Google Drive API.
I am using this ProGuard configuration. There are no Exceptions thrown - everything seems to work fine - just the requests fail.
Any ideas?
I just found the reason why it failed.
Not proguard is the issue. I genereated a SHA-Hash and entered it in the Google API Console for my app. The release version is signed with another keystore and I had to generate another SHA-Hash for this version.

android LicenseValidator : Signature verification failed

I'm having a problem with the LVL in one app.
We have around 10 Apps in that we are using License check, but today only one App is not working. Its showing Signature Verification Failed error. All 10 apps are using the same licensing library, apart from one app all are working perfectly fine. Not getting why its not working. The Key I'm using is definitely correct!
The error I get in logcat is:
12-12 15:22:07.000: E/LicenseValidator(6783): Signature verification failed.
And the dontAllow() function of the LicenseCheckerCallback is run.
I'm testing the apps on a Nexus One.
1st, double check the BASE64_PUBLIC_KEY in the app against the Developer Console -> Development Tools -> Services & APIs Base-64 code.
2nd, do not change the versionCode in the gradle files until you are ready to "Build -> Generate Signed APK" and upload it to the store. Version codes that haven't been used in uploaded previous versions come back unlicensed.
3rd, make sure that the user, who is signed in on the device, does have a license (either real or tester).
4th, make sure that the internet connection works on the device.
The problem for me was that I changed the versionCode in my AndroidManifest file, but the new version was not know to the Google developer console. After uploading the new apk, the error disappeared.
This is kind of a bizarre solution but it worked for me:
I logged into the Android Developer Console, navigated to the Edit Profile screen, and reset my License Test Response to a different value. After saving, I reset the test response back to what it was before and saved again. After I did that, the error disappeared and everything worked fine.
In my experience, the test response stuff is very brittle. I've seen it reply with incorrect stuff, even when using StrictPolicy. This blog post mirrored my experience exactly:
Android License Test Response - Never Works

Categories

Resources