You need to follow the following steps to fix this:
Delete the google-services.json file from your project.
From the build.gradle file, remove the classpath ‘com.google.gms:google-services:x.x.x’ line.
In the application level build.gradle file, i.e. the build.gradle file inside app folder, remove id ‘com.google.gms.google-services’ from the plugins{} block. Also remove any implementation of Firebase from the dependencies block. For example, if you have implementation ‘com.google.firebase:firebase-database-ktx:x.x.x’ for firebase database, remove it.
Invalidate the cache and restart Android Studio. To do that, open Android studio, click on File and click on Invalidate cache/restart option to restart Android studio.
Android studio invalidate cache/restart
Once it is done, connect to firebase again from Firebase assistant window. Click on Tools in the Android studio menu and click on Firebase to open the assistant window.
Firebase assistant android studio
You can login to the new Firebase account from this window and it will connect your project with the new account. You can restore all dependencies of Firebase once it is connected to the new account. It also downloads the firebase .json file and adds all firebase related configs in the build.gradle files.