ProGuard meets Drive API - android

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.

Related

Firebase Authentication fails with FirebaseException: Instantiation of JsonResponse failed

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.

java.io.IOException: FIS_AUTH_ERROR in Android Firebase but DEBUG mode ok

I have the following issue while retrieving firebase Token with
FirebaseMessaging.getInstance().getToken()
in DEBUG mode I get the token and I send it to the server
in RUN mode, the app works fine, it's published BUT I can't get the token since I've got thanks to Crashlytics #Firebase console
java.io.IOException: FIS_AUTH_ERROR
I tried all suggested solutions found here java.io.IOException: FIS_AUTH_ERROR in Android Firebase without success
Library used, build.gradle (:app)
implementation platform('com.google.firebase:firebase-bom:26.7.0')
I realized that I didn't add my dev certificates to the APIs that that flavour was using.
Let me just copy+paste the answer I gave in another thread:
If you have your APIs keys restricted (which you should), make sure you add your dev certificate and bundle ID to the key/s.
Visit your dashboard, select the project from top bar -> API keys and there you should see them (auto created by Firebase).
Hope this solves your problem!
EDIT: More details about this issue (see comments).
You should only need 1 SHA/instance and for release only for the signing certificate. I will advice you to use flavours for each different part of dev/testing/release. Each dev should provide the local debug certificate and these can be used to sign in app distributed via Firebase, for example. Separate, a set of production APIs which will be best to restrict on the release certificate ONLY.
Just remember that every new PC used for developing will require to provide the SHA to be added in the restrictions. It will be a ride to forget about this part! :)
Good luck!

Certificate pinning issue after adding Fabric crashlytics

I am using fabric crashlytics in my android and iOS app. I integrated the fabric according to the documentation and everything is working fine. I am able to see the crashlytics and other data in the dashboard.
The issue is I did a penetration testing using IBM analyzer tool (free trial) and the result shows that there is an issue and the issue is certificate pinning issue. Now to confirm whether it is due to fabric/crashlytics I removed fabric and crashlytics from my project and ran penetration testing again. This time it does not show me any issue.
So my question is how is data passed between app and fabric servers and what can be done to solve this issue.
I have done the testing only with a .apk file. Will it be same for .ipa file also?
It's possible to view requests and responses of several endpoints from crashlytics.com in plain JSON with some help of SSL proxy tools like Charles. e.g.
The data is passed via HTTPS but no cert pinning is applied. It will be the same for .ipa file.
I personally don't think it's a serious issue. Just avoid sending sensitive data to crashlytics logs.

Google Drive API is not working after Proguard obfucation

I am using
compile 'com.google.android.gms:play-services-auth:10.0.1'
compile 'com.google.android.gms:play-services-drive:10.0.1'
to implement Google Drive in my Android app. The app is working well until i obfuscate the application with Proguard. Once the application is obfuscated, while i try to enable Google Drive Backup option, the app pop-ups the account selection dialog and doesn't proceed after that.
In the debug version of the app, while i try to enable Google Drive Backup option, the app pop-ups the account selection and then proceed to Google Drive Permission dialog to access the drive files.
I have read that Google added the Proguard rule for the Google Play Services and wonder what could be the issue in my case. I have also tried the Proguard rules suggested in the following StackOverFlow threads
Google Drive API doesn't play well with ProGuard (NPE)
Release apk not working after enabling proguard, not able to debug too
How to fix Proguard issue with Google Drive REST API
But, the provided solutions didn't work for me. Is there any new rules to be added for the latest Google Drive API to work?
As suggested here, you can check what gets taken away by looking at the ProGuard output files. Also based from this blog, it was definitely a Proguard problem. It was also noticed that one of the debug statements indicated that the Files object had some obfuscated fields that were probably causing a problem. A quick look at the class file showed that this class had some annotations and we’d seen references in Proguard to keep annotations.
You may also check on this thread if it helps.

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

Categories

Resources