12

How can I generate the right release key hash in Ubuntu? I have already referred this but i can't get my answer.

Community
  • 1
  • 1
pRaNaY
  • 24,642
  • 24
  • 96
  • 146

1 Answers1

24

After trying many time i got solution for fragment which give me a release key hash.

try {
        PackageInfo info = getActivity().getPackageManager().getPackageInfo(
                "com.yourappname.app",
                PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            Log.d("KeyHash", "KeyHash:" + Base64.encodeToString(md.digest(),
                    Base64.DEFAULT));
            Toast.makeText(getActivity().getApplicationContext(), Base64.encodeToString(md.digest(),
                    Base64.DEFAULT), Toast.LENGTH_LONG).show();
        }
    } catch (PackageManager.NameNotFoundException e) {

    } catch (NoSuchAlgorithmException e) {

    }

enter image description here

And i got this command from here for terminal which give me release key hash.

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64
Community
  • 1
  • 1
pRaNaY
  • 24,642
  • 24
  • 96
  • 146