Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

released apk #30

Closed
shikhakothiyal opened this issue Dec 17, 2018 · 36 comments
Closed

released apk #30

shikhakothiyal opened this issue Dec 17, 2018 · 36 comments

Comments

@shikhakothiyal
Copy link

Hash key generated is not working for released apk. Do we have different keys for released and debug mode. What changes in program we need to make to get the key for released mode.

@Rissmon
Copy link

Rissmon commented Jan 1, 2019

Facing the related issue with SMS Retriever API. Once the application is downloaded from the play store the automatic msg reading is not working.

@PemmasaniRajesh
Copy link

I'm also facing the same issue. I've generated the haskey using AppSignatureHelper class and it is working fine in release mode also. But when I downloaded the apk from playstore, it is not working

@shikhakothiyal
Copy link
Author

Go to build gradient ->and change debugging mode to release mode -> now again run the code and you will get a new key.

@PemmasaniRajesh
Copy link

PemmasaniRajesh commented Jan 5, 2019

It is working in release mode, when i download the apk from playstore it is not working. Google App Signing is enabled for my app. Is this the case, it is not working?

@Rissmon
Copy link

Rissmon commented Jan 5, 2019

@PemmasaniRajesh It's the same issue I am facing. Any solution to this problem?.

API is working for debug and release build but once uploaded to playstore with Google App Signing is enabled SMS Retrieval API stop working.
I even tried generating the hashkey using AppSignatureHelper from the playstore downloaded build and still, I am facing the same issue.

@Rissmon
Copy link

Rissmon commented Jan 5, 2019

Go to build gradient ->and change debugging mode to release mode -> now again run the code and you will get a new key.

@shikhakothiyal It will work for release and debug build. We are facing this issue when the same build is downloaded from playstore.

@sahil994
Copy link

sahil994 commented Jan 7, 2019

Facing same issue the API is working fine for release and debug build and does not work when i downloaded from Play Store.

@ithinkihaveacat
Copy link
Contributor

Are there any messages in the logs?

@Rissmon
Copy link

Rissmon commented Jan 7, 2019

@ithinkihaveacat Issue exists only for the play store build so I'm not able to extract any logs.

@vikas56
Copy link

vikas56 commented Jan 8, 2019

keep log for playstore build and check hash key generated.Because signed apk,debug apk and playstore build apk have different hash keys.Give that hash key of playstore build to backend folks.

@Rissmon
Copy link

Rissmon commented Jan 8, 2019

keep log for playstore build and check hash key generated.Because signed apk,debug apk and playstore build apk have different hash keys.Give that hash key of playstore build to backend folks.

Yes i tried that but still same issue

@PemmasaniRajesh
Copy link

keep log for playstore build and check hash key generated.Because signed apk,debug apk and playstore build apk have different hash keys.Give that hash key of playstore build to backend folks.

Yeah this is working for me....

@sureshperiyasamy
Copy link

keep log for playstore build and check hash key generated.Because signed apk,debug apk and playstore build apk have different hash keys.Give that hash key of playstore build to backend folks.

Yeah this is working for me....

@PemmasaniRajesh Are you generating Hash key using AppSignatureHelper class ?

@kunalsale
Copy link

I'm facing the same issue. It is working fine in debug build as I'm using AppSignatureHelper for hash key. I used the following command to generate the hash for signed build:

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`

But SMS is not getting auto retrieved. Is there any solution for the issue?

@sureshperiyasamy
Copy link

I'm facing the same issue. It is working fine in debug build as I'm using AppSignatureHelper for hash key. I used the following command to generate the hash for signed build:

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`

But SMS is not getting auto retrieved. Is there any solution for the issue?

Use this ruby script and get hash key it worked fine for me
https://github.com/michalbrz/sms-retriever-hash-generator/blob/master/google_play_sign.rb

@shivamverma676
Copy link

shivamverma676 commented Mar 12, 2019

Facing same issue the API is working fine for release and debug build and does not work when i downloaded from Play Store.

So i found the solution, i have provide the play store generated hash to backend. For generate hash key on playstore, i have used AppSignatureHelper class and make Toast for the generated hash key and upload this build on play store. After successfully rollout, i have download the build. Now Toast will show with the playstore generated hash key, provide this key to backend. It is working fine for me.

@taufik1993
Copy link

I am using SMS API for read OTP, I have uploaded build on play store and install in mobile from play store, first time message was not read but when i kill application and run again it is work, Why?

@taufik1993
Copy link

taufik1993 commented Mar 27, 2019

I'm facing the same issue. It is working fine in debug build as I'm using AppSignatureHelper for hash key. I used the following command to generate the hash for signed build:
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`
But SMS is not getting auto retrieved. Is there any solution for the issue?

Use this ruby script and get hash key it worked fine for me
https://github.com/michalbrz/sms-retriever-hash-generator/blob/master/google_play_sign.rb

When i am running this file this way
ruby google_play_sign.rb --package com.your.app --google-play-key deployment_key.der,
and
ruby google_play_sign.rb --package com.your.app --keystore keystore.jks --keystore-password mypassword --key-alias myalias

but getting this result
'shasum' is not recognized as an internal or external command,
operable program or batch file.
Your SMS hashcode is:

@shikhakothiyal
Copy link
Author

shikhakothiyal commented Mar 27, 2019 via email

@taufik1993
Copy link

Change the build variant setting to release mode and regenerate your key. Use this key for verification and everything will work fine.

On Wed, Mar 27, 2019, 5:10 PM Taufik Hussain @.***> wrote: I'm facing the same issue. It is working fine in debug build as I'm using AppSignatureHelper for hash key. I used the following command to generate the hash for signed build: 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` But SMS is not getting auto retrieved. Is there any solution for the issue? Use this ruby script and get hash key it worked fine for me https://github.com/michalbrz/sms-retriever-hash-generator/blob/master/google_play_sign.rb How to run this file? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#30 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AbPHx4UfeXeFH2_YtcLJ6NwUW0bnER9fks5va1izgaJpZM4ZVxqA .

I have changed build variant but getting same issue first time message was not read but when i kill application and run again its work why??
If i am wrong please suggest me.

@taufik1993
Copy link

keep log for playstore build and check hash key generated.Because signed apk,debug apk and playstore build apk have different hash keys.Give that hash key of playstore build to backend folks.

First time message was not read but when i kill application and run again its work why??

@VikhyatC
Copy link

keep log for playstore build and check hash key generated.Because signed apk,debug apk and playstore build apk have different hash keys.Give that hash key of playstore build to backend folks.

Yeah this is working for me....

@PemmasaniRajesh Are you generating Hash key using AppSignatureHelper class ?
I am using AppSignatureHelper to generate hash and facing the same issue.any suggestions? I'm kind running late from my deadline!

@PemmasaniRajesh
Copy link

Yes, I'm using the AppSignatureHelper class only....

@VikhyatC
Copy link

Yes, I'm using the AppSignatureHelper class only....

does it work for you?

@PemmasaniRajesh
Copy link

Yup....

@VikhyatC
Copy link

I'm using this link to generate a app hash. https://github.com/googlesamples/android-credentials/blob/master/sms-verification/android/app/src/main/java/com/google/samples/smartlock/sms_verify/AppSignatureHelper.java. am i missing something?.Since this implementation is working on release and debug app but not the app downloaded from playstore.

@PemmasaniRajesh
Copy link

Yeah, I'm also using the same class. I don't know how you're generating the hashkey in release mode.

The hashkey is different for release build and playstore build. First release the app in playstore by generating the hashkey in some screen of your app as toast message. Once you download the app from playstore, you can get the hashkey and save it. After this, release the app once again in playstore with the new hashkey.

@taufik1993
Copy link

I'm using this link to generate a app hash. https://github.com/googlesamples/android-credentials/blob/master/sms-verification/android/app/src/main/java/com/google/samples/smartlock/sms_verify/AppSignatureHelper.java. am i missing something?.Since this implementation is working on release and debug app but not the app downloaded from playstore.

I facing same issue but when i have registered my BroadcastReciever class inside AndroidManifast.xml It's working fine for me.

@VikhyatC
Copy link

Yeah, I'm also using the same class. I don't know how you're generating the hashkey in release mode.

The hashkey is different for release build and playstore build. First release the app in playstore by generating the hashkey in some screen of your app as toast message. Once you download the app from playstore, you can get the hashkey and save it. After this, release the app once again in playstore with the new hashkey.
Thanks i shall try this method although i will have to create an internal release first since its also stated in the documentation that the AppSignatureHelper class has to be removed before releasing it for production.However will the keys change for alpha and production builds?

@PemmasaniRajesh
Copy link

I'm not sure about this. I've tried in production only and it worked. I hope it will not change for alpha and production builds.

@Developer101253
Copy link

Yeah, I'm also using the same class. I don't know how you're generating the hashkey in release mode.

The hashkey is different for release build and playstore build. First release the app in playstore by generating the hashkey in some screen of your app as toast message. Once you download the app from playstore, you can get the hashkey and save it. After this, release the app once again in playstore with the new hashkey.

But I can't go for a sample play store release just to get the hash. Can someone help in providing an offline way to generate the hash

@Developer101253
Copy link

Guys, Found the perfect solution for the issue "SMS retriever API is working for release build but not for the app downloaded from the play store"

This is because of the process that Google does to sign the app. The key that you have (key.jks) is not a app sign in key rather it is an upload key to the play store console, The play store decodes the app with the upload key and signs the app again with the signing key which is stored in the play store console.

That is the reason why we are not able to use the SMS retriever API as there will be a key mismatch.

You can use this resource to download the deployment_cert.der and convert it to its jks and the use that to generate the 11 digit hash.

https://stackoverflow.com/questions/51365778/how-to-generate-11-char-hash-key-for-sms-retriever-with-google-app-signing/51375789

@Rissmon
Copy link

Rissmon commented May 3, 2019

Guys, Found the perfect solution for the issue "SMS retriever API is working for release build but not for the app downloaded from the play store"

This is because of the process that Google does to sign the app. The key that you have (key.jks) is not a app sign in key rather it is an upload key to the play store console, The play store decodes the app with the upload key and signs the app again with the signing key which is stored in the play store console.

That is the reason why we are not able to use the SMS retriever API as there will be a key mismatch.

You can use this resource to download the deployment_cert.der and convert it to its jks and the use that to generate the 11 digit hash.

https://stackoverflow.com/questions/51365778/how-to-generate-11-char-hash-key-for-sms-retriever-with-google-app-signing/51375789

@Developer101253 Same thread solved my issue.

Downloaded the DER formatted file from play store console. Then converted it to a .jks file using the following command:
keytool -importcert -ALIAS_NAME paxapp -file deployment_cert.der -keystore certificate.jks -storepass KEYSTORE_PASSWORD

Note:
Replace:

  • ALIAS_NAME with your key alias name.
  • KEYSTORE_PASSWORD with your password.

Use the below command on jks file:
keytool -exportcert -alias ALIAS_NAME -keystore certificate.jks | xxd -p | tr -d "[:space:]" | echo -n PACKAGE_NAME cat | sha256sum | tr -d "[:space:]-" | xxd -r -p | base64 | cut -c1-11

Note:
Replace:

  • ALIAS_NAME with your key alias name.
  • PACKAGE_NAME with your package name.

@Teja-Batchu
Copy link

Add this code in your app Computing app's hash string code. then you will get hash key for a specific device (debug device). Add verbose logs for hashkey like Log.v("Hashkey ", hash); then upload this apk into play store after download it from store then log it you will get hash key for production apk. Update that hash key into your server it will work

@ithinkihaveacat
Copy link
Contributor

Thanks to everyone in this thread for raising this, and providing solutions. We've updated the documentation accordingly:

https://developers.google.com/identity/sms-retriever/verify#computing_your_apps_hash_string

@codingjeremy
Copy link
Contributor

I am closing this issue/PR, as it has been migrated to the new repo linked above in the comments. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests