Find Debug Hash key using Code
If you get a debug hash key from using Code in Android, you must try this code.
try {
PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.e("MY KEY HASH:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
Log.e("KEY HASH ERROR:", "NameNotFoundException: " + e.getMessage());
} catch (NoSuchAlgorithmException e) {
Log.e("KEY HASH ERROR:", "NoSuchAlgorithmException: " + e.getMessage());
}
Put this code into MainActivity.java
into onCreate()
function and run the app, you will find key in logcat
Last updated