Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generated 11 char hash code is not working after google app signing is enabled

Tags:

android

sms

I am trying to implement Sms Retriever for fetching an otp from user mobile without having any SMS permission.

Initially, I have generated a hash key with the keystore(.jks) by using keytool as described here

when I signed the apk with this keystore and received the SMS with this hashkey, it is working properly.

But After uploaded the app to google play store, the SMS receiver is not working .we have enabled google app signing to sign the app. I found that Google will remove the uploaded signature, a key for the apps using google app signing as described here. So, I was trying to add the google app signing certificate to the uploaded keystore with the alias name for creating new hashkey.But I am unable to add the app signing certificate to the keystore with alias name.

Any suggestions to generate the hashkey with app signing certificate for sms retriever?

like image 345
Ajay Jayendran Avatar asked May 29 '18 16:05

Ajay Jayendran


People also ask

How to change app signing key certificate?

Step 1:- Go to your Google Play Console and Select your App. Step 2:- Go to Release Section => Setup => App integrity and Click on Request key upgrade.

How to generate upload key Google Play?

In the Google Play Console App Signing page, select “Export and upload a key from Android Studio” and upload the key Android Studio generated. If you're using a Java keystore to sign your apps, select the “Export and upload a key from a Java keystore” in the Google Play Console App Signing page.

Where is app signing by Google Play?

Open one of your Android projects (choose one at random). Go to Build -> Generate Signed APK and press Create new.


2 Answers

When Google's App Signing enable 11 char hash will be generated without alias

i.e SMS Retrieve API

The following command computes the hash string from your app's production keystore:

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

in the above command hash is generating based on MyAndroidKey alias (-alias MyAndroidKey).

Try generating hash without alias for Google APK Sign Enabled

i.e

keytool -exportcert -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
like image 92
Suresh Avatar answered Oct 15 '22 11:10

Suresh


Since, Play App is also signing app so we have to generate a .jks file and we'll have to use this .jks file produced by the deployement_cert.der (Downloaded from Google play console), for getting the 11 char hash code. follow the steps:

The .jks file is required to generate the 11 char hash code,

To create .jks file

  1. Download .der file from google play console.

    https://i.stack.imgur.com/KUK6i.png

  2. To create .jks file from the downloaded certificate (deployment_cert.der ) use this command:

keytool -importcert -alias YOUR_ALIAS -file deployment_cert.der -keystore app_keystore.jks -storepass YOUR_KEYSTORE_PWD

It will generate a app_keystore.jks file.

3. Then use the generated keystore for generating the 11 char hashcode.

keytool -exportcert -alias YOUR_ALIAS -keystore app_keystore.jks | xxd -p | tr -d "[:space:]" | echo -n COM.EXAMPLE.MYAPP cat | sha256sum | tr -d " [:space:]-" | xxd -r -p | base64 | cut -c1-11

like image 40
Arjun Saini Avatar answered Oct 15 '22 10:10

Arjun Saini