skip to Main Content

I would like to share that I wasn’t able to find on StackOverflow. I will be sharing what I have done so far and the respective output which I have never faced before.

What I have done:

  1. Followed the FB login implementation doc and added my LoginActivity for default deep link transactions from Facebook SDK.
  2. I created the debug key hash and getting unusual hash-key from the CLI like the image below. In the image you may see there, = is missing. generating the debug hash
  3. I am not able to use this key hash while implementing the login API of Facebook. It says the key-hash must end with an = character. Ref: in this image below.
    enter image description here

And the same thing is happening with my release hash key. So how can I get rid of this kind of problem?

2

Answers


  1. if you have ssl executor then try this

    keytool -exportcert -alias androiddebugkey
    -keystore "$PATHdebug.keystore" | "$OPENSSL_PATHbinopenssl" sha1 -binary |"$OPENSSL_PATHbinopenssl" base64
    }
    

    Alternative:

    Step 1

    go to http://tomeko.net/online_tools/hex_to_base64.php

    Step 2

    paste the SHA-1 in the first field

    Step 3

    copy the text in input field under "Output (base64)"

    Step 4

    now open developer.facebook.com/apps
    click your app
    on the left side navigate to "Settings" -> "Basic"
    past the Base64 text here under key hashes

    Login or Signup to reply.
  2. Here is the fastest way to get SHA-1 key. Please follow below steps.

    1. Open Android Studio
    2. Open your Project
    3. Click on Gradle (From Right Side Panel, you will see Gradle Bar)
    4. Click on Refresh (Click on Refresh from Gradle Bar, you will see List Gradle scripts of your Project)
    5. Click on Your Project (Your Project Name form List (root))
    6. Click on Tasks
    7. Click on Android
    8. Double Click on signingReport (You will get SHA1 and MD5 in Run Bar(Sometimes it will be in Gradle Console))

    Example

    enter image description here
    Select app module from module selection dropdown to run or debug your application

    And then call following function in onCreate of your activity

    or

    In App following code to generate hash key. And then run your app you can check you hash key in logcat.

    fun generateHashKey(context: Context){
        try {
            val info = context.packageManager.getPackageInfo(context.packageName, PackageManager.GET_SIGNATURES)
            for (signature in info.signatures) {
                val md = MessageDigest.getInstance("SHA")
                md.update(signature.toByteArray())
                val hashKey = String(Base64.getEncoder().encode(md.digest()))
                Log.i("AppLog", "key:$hashKey=")
            }
        } catch (e: Exception) {
            Log.e("AppLog", "error:", e)
        }
    
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search