1

I am trying to get the key hash for a release keystore.

Tried below two methods which gives different key's but none works.

Method 1:

 // Add code to print out the key hash
try {
    PackageInfo info = getPackageManager().getPackageInfo(
            <MYPACKAGE>, 
            PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
        }
} catch (NameNotFoundException e) {

} catch (NoSuchAlgorithmException e) {

}

Method 2:

On Windows, use:

keytool -exportcert -alias <mykeystorelias> -keystore <keystorepath> | openssl sha1 -binary | openssl base64

But method 1 worked for the debug keystore.

  1. The release keystore was created by me from eclipse and don't have an extention to the name.
  2. it asks for the password when I used method 2
vinod
  • 53
  • 7

1 Answers1

0

if you want to test the app in debug mode..please try to run following command in windows cmd

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 

when prompted for password ,enter 'android'

for release version, use your release certificate that you have created via eclipse export and run the following command in windows cmd

keytool -exportcert -alias <mykeystorelias> -keystore <keystorepath> | openssl sha1 -binary | openssl base64

use the same password that you have used for exporting the app in eclipse

Sam
  • 4,046
  • 8
  • 31
  • 47