Facebook login error Kotlin — Android

Sudhanshu Srivastava
1 min readApr 4, 2023

If you are facing error in facebook login and getting error message saying

“This app has no Android key hashes configured. Configure your app key hashes at https://developers.facebook.com/apps/YOUR_FB_APP_ID”

This app has no Android key hashes configured. Configure your app key hashes at https://developers.facebook.com

Then this is what you need to do.

You need to create a Key hash and add it here

How to generate Key hash

You can add this function and add to your Activity.kt file and call it like this.

This is temporary function just to get the hash key which you should remove once you get the “KeyHash: YOUR_HASH_KEY”

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
generateFBHashKey()
}
private fun generateFBHashKey() {
try {
val info: PackageInfo = packageManager.getPackageInfo(
"com.bundle.id",
PackageManager.GET_SIGNATURES)
for (signature in info.signatures) {
val md = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT))
}
} catch (e: PackageManager.NameNotFoundException) {
} catch (e: NoSuchAlgorithmException) {
}
}

Note: You’ll have to create Key hashes for all the build variants you have.

--

--

Sudhanshu Srivastava

I write about what I learn. Swift, Kotlin, Flutter, Social and Life.