The signed app works fine but as soon as I upload the app to play store, the firebase phone authentication throws Unexpected response code 400 for https://www.googleapis.com/identitytoolkit/v3/relyingparty/sendVerificationCode? error.
I found a solution much easier to do.. All you need to do is link your Firebase account to your google Play console, you can do this from firebase console.
Project settings->Account linking->Google Play. Hope it works for you.
By doing this it will add/register all your app signing certificates SHA1 to firebase
Can you try to add a new SHA1 code on Firebase?
If you try to build the project on other computer or you re-install your OS, you may face this problem.
In those cases, you can create a new SHA certificate fingerprint and add it to the settings of your firebase project.
I hope it would help you.