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

后端 未结 5 1540
悲&欢浪女
悲&欢浪女 2021-02-02 17:16

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 ke

相关标签:
5条回答
  • 2021-02-02 17:53

    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))
            }
    
    0 讨论(0)
  • 2021-02-02 17:56

    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));
    }
    
    0 讨论(0)
  • 2021-02-02 17:57

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

    0 讨论(0)
  • 2021-02-02 18:08

    Finally, I resolved the issue.

    Reason Behind this issue While publishing an App to play store, I did APP SIGNING from Google Play, hence new SHA-1 key was created there.

    To see this key, go to Google Play Console, select your app, then Release Management -> App Signing

    On this page, I got new SHA-1 key under section "App signing certificate "

    So, the point is Google Play Signing creates a new certificate as shown in above image.

    In Facebook developer account, we need to add Key hashes generated by our keystore. But in this case, we also need to add Key hash corresponds to this APP SIGNING certificate. Now the question is, how to get key hash for this certificate/SHA-1 fingerprint?

    How to create Key Hash from SHA-1 key of Google Play APP SIGNING?

    To generate key hash from SHA-1 key, execute a small Java program,

    // GOOGLE PLAY APP SIGNING SHA-1 KEY:- 65:5D:66:A1:C9:31:85:AB:92:C6:A2:60:87:5B:1A:DA:45:6E:97:EA
                byte[] sha1 = {
                        0x65, 0x5D, 0x66, (byte)0xA1, (byte)0xC9, 0x31, 0x85, (byte)0xAB, (byte)0x92, (byte)0xC6, (byte)0xA2, 0x60, 0x87, 0x5B, 0x1A, (byte)0xDA, 0x45, 0x6E, (byte)0x97, (byte)0xEA
                };
                System.out.println("keyhashGooglePlaySignIn:"+ Base64.encodeToString(sha1, Base64.NO_WRAP));
    

    Output:-

    keyhashGooglePlaySignIn: ZV1dkSgxvc2p4aCtFx9tcaQr8N4=
    

    Copy this key hash and paste it to Facebook Developer account settings for your app. This is how my problem got solved.

    Thanks all developers for comments. :)

    0 讨论(0)
  • 2021-02-02 18:13
    echo SHA1_here | xxd -r -p | openssl base64
    

    Does the same work as the above code.

    0 讨论(0)
提交回复
热议问题