Getting different App's Hash String every time | SMS Retriever API

1.4k Views Asked by At

I am integrating SMS Retriever API in my android app.

I followed below docs to generate app's hash string:
https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string

Following are the ways to generate Hash:
1) Command

keytool -exportcert -alias MyAndroidKey -keystore MyProductionKeys.keystore | xxd -p | tr -d "[:space:]" | echo -n com.example.myapp `cat` | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11

2) AppSignatureHelper class

I got different hashes for different methods

prodRelease(using command) - R2J*******N
prodRelease(using AppSignatureHelper class) - ROI*******6

and also different hashes for different build variants.

prodRelease: ROI*******6
prodDebug: CAz*******N
devRelease: R2J*******N
devDebug: ROI*******6 (Same as prodRelease)

I tested my app with SMS template with prodRelease hash i.e ROI*******6. It was working great and then after two days, it stopped working. I debug and now the hashes are different again and now it works with different hash R2J*******N.

I expect the Hashes to be same as it depends on the app's package id.
So why different hashes and which Hash to consider correct one or is it going to change every time and I have to keep changing the SMS template in the server?
Or is there any other better way to be sure about the hash?

1

There are 1 best solutions below

0
On

Yo need one hash for every build variant.

1- Debug 2- Release 3- If you sign your app in google play console you need another one, because google change the hash when you upload the app