I've had used a firebase account for my android project, and recently I faced some issues with the account so I decided to create a new one and link my project to this newly made project.
Everything seemed to work fine, but when I tried to use firebase auth, I faced an error which says: API key not valid. Please pass a valid API key.
I searched for hours and all I could find was that I had to redownload google-services.json file and replace it. I did it and I still get the same error
Anyone knows what I have to do? Thanks in advance.
I also faced the same issue and in my scenario API key in json file was expired, just follow the following simple steps
1 - Open firebase console and go to project settings.
2 - In project setting under general tab ou can see Web Api Key. Copy that key.
3- Open Android Studio and open google-service-json which is present in app directory.
4- In json file you can see the API key just changed that key with the one you copied from firebase console and boom you are good to go .
After trying all thing that I found on the web about this problem, the thing that worked for me is Clean Build then Invalidate cash and restart
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
My local android app is synced up in google firebase console with my SHA key configured in google.services.json. How do the developer on other end
can setup the project to use the same firebase console and json file.
We are trying phone based authentication. While setup at my end works is fine, but the developer on the other end is getting this error - This operation is not allowed. You must enable this service in the console.
Please help me with the correct way to do this.
Solution:
So for other developers, generate the SHA-1 Key as described in the picture
Go to Firebase Console:
Settings
Your Apps
Add Fingerprint and paste the SHA.
A solution for the comment:
So the answer is well written in the error. You can't have two projects of the same package name. Even if you delete it. It will take a least 4-5 days to get deleted fully from the developer's console.
So the only solution is to generate a new SHA-1 key by custom signing the app by generating a signed apk from the android studio. Or just create a new project with different package name both ways will work for now.
Hope this info helps. Do let me know if it changes anything for you.
Adding to Sharan's answer, that is the correct one, you can add those SHA1 keys in your Firebase console going to
Project configuration - ADD FINGERPRINT
Remember to select the correct project at the Android apps panel in order to add those keys
I have integrated Google login in my Android application before one month. Now I am planning to launch another application with different package name. I am trying to implement Google login in this application too.
When I have generated and pasted SHA 1 to google and its giving error like below
Duplicate fingerprint
The fingerprint you specified is already used by an Android OAuth2 client ID in this project or another project
I want know that SHA 1 is same for all project in same machine even We change package name in application ?
What is solution for use Google login in another application ? I am confused because Google ask package name with Google Auth. I have marked that in new package also Google signin working fine but it will cause issue in future ?
Every app has a different SHA key fingerprint. You need to update it for every project that you make.
For Example: If I am updating my app and I create a new project, ill have to add another SHA key to the firebase project under the settings of the app in firebase.
Just a few days ago I have changed my SHA-1 fingerprint (from signing to dev) for testing purpose. Now I want to go back to signing SHA-1 but it's not allowing me to add live SHA-1 fingerprint. It gives me duplicate fingerprint error.
I am sure that we do not have any other client id already registered with the app's fingerprint. We don't have any deleted project as well. My app is already in the Store I can't simply change the package or the keystore to make it work.
While updating SHA-1 fingerprint in the Google Cloud Platform developer console, I get the following popup:
Duplicate fingerprint
The fingerprint you specified is already used by an Android OAuth2 client ID in this project or another project
Anyone with a similar problem that managed to reach a solution?
You have to go to your API console and undelete your old project that contains the OAuth ID that you are trying to use for your new project.
One of the previous projects that I had already deleted still contained it.
You couldn't add the new OAuth because it "already existed" even though your project did not contain that ID already.
When you delete a project in the API console, the OAuth IDs associated with it seem to not get deleted with it.
This should really be changed!
I found a fix to this problem.
When the console asks you for the SHA1 and Package name for a new API that you are using in the same app.
Just keep the same SHA1 code and change the Package name a little.
Eg: com.example.exampleapp to com.example.exampleapp1 .
I know this is not a full proof solution but i have many different google API calls in my app by just changing the package name a little.
I tried many solution from This but my simple fix helped me move on.
Hope this helps you.