androidandroid-studiohashfacebook-android-sdk

Generating release key hash in Linux OS(Ubuntu) : Android Facebook SDK


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


Solution

  • 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