First configure Facebook sdk and then the main program, if you add this, you will get keyhash on the console
There will be chances that 3 types of keys are debugged once, and the other is the release key, and after downloading the signature with google changes you can provide all these 3 keys for the facebook developer account, after which you can check the facebook login. depending on your application mode facebook will match the key. Use a toast to see keyhash if you don't know the Android monitor from Android studio.
import com.facebook.FacebookSdk; import com.facebook.appevents.AppEventsLogger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); printKeyHash(); } private void printKeyHash() { try { PackageInfo info = getPackageManager().getPackageInfo( getPackageName(), PackageManager.GET_SIGNATURES); for (Signature signature : info.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); Log.i("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT)); } } catch (PackageManager.NameNotFoundException e) { Log.e("jk", "Exception(NameNotFoundException) : " + e); } catch (NoSuchAlgorithmException e) { Log.e("mkm", "Exception(NoSuchAlgorithmException) : " + e); } }
}
source share