Facebook login in my android app is working fine in release apk, but not working properly after publishing the same apk on play store

Viewed 14379

In my android application, I used facebook login. It is first time ever I used it.

The login functionality is working fine in release apk file. Also, I have generated key hash by using keytool, openssl:-

keytool -exportcert -alias "MyAppAlias" -keystore "Path to keystore" | 
openssl sha1 -binary | openssl base64

I added the generated key hash in App settings on my Facebook developer account. Now when I am generating Signed apk, Facebook login is working fine, but after publishing the same apk on Play Store, Facebook login is not working, it's simply redirecting to activity from where it was called(My App's login activity) without any crashes or not responding message.

Thanks.

7 Answers

I improved @vChamps answer a bit. just pass the SHA1 string to below function

public void hashFromSHA1(String sha1) {
    String[] arr = sha1.split(":");
    byte[] byteArr = new  byte[arr.length];

    for (int i = 0; i< arr.length; i++) {
        byteArr[i] = Integer.decode("0x" + arr[i]).byteValue();
    }

    Log.e("hash : ", Base64.encodeToString(byteArr, Base64.NO_WRAP));
}
echo SHA1_here | xxd -r -p | openssl base64

Does the same work as the above code.

Copy Paste the SHA1 key here to Reduce all the Headache.Link Internallly its converting Hex to Base 64.

Kotlin code:

        import android.util.Base64
        import android.util.Log

        fun hashFromSHA1(sha1: String) {
            val arr = sha1.split(":".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
            val byteArr = ByteArray(arr.size)

            for (i in arr.indices) {
                byteArr[i] = Integer.decode("0x" + arr[i])!!.toByte()
            }

            Log.e("hash : ", Base64.encodeToString(byteArr, Base64.NO_WRAP))
        }

If you already have your SHA1 key you can use the online converter tool - to generate your hash code here

Related