Android has added Play Integrity API you can read more here. For OTP to work you need to do the following:
Enable Play Integrity responses
To use the Play Integrity API, you must enable Play Integrity API responses by linking your app to a Google Cloud project. Then follow the instructions to integrate the API into your app.
Apps on Google Play
In the Play Console, navigate to the Release section of the left menu. Go to Setup > App integrity. Select the Integrity API tab to get started.
Apps exclusively distributed outside Google Play
You can enable Play Integrity API responses for your app without using the Google Play Console. To do so, complete these steps:
Choose an existing project or create a new project from the Google Cloud Console.
Go to APIs and services and select enable APIs and services.
Search for Play Integrity API. Select it and then select Enable.
Select Project & APIs
Enable API keys
Search api
SHA Keys
If you haven't yet specified your app's SHA-256 fingerprint, do so from the Settings Page of the Firebase console. For more info read details here.
How to generate the app SHA1 and SHA256
You need to configure firebase phone auth for phone otp verification to work, without this you would running into errors building the app.
To solve this error, you need to add both your keystore SHA1 and SHA56 as well as debug SHA1 and SHA256 to fireabse console.