How to create a Facebook key hash?

前端 未结 9 1124
独厮守ぢ
独厮守ぢ 2020-12-14 13:15

In the Facebook android tutorial we are told to use following code to create a key hash:

keytool -exportcert -alias androiddebugkey -keystore ~/.andro

相关标签:
9条回答
  • 2020-12-14 13:39

    You can create this way

    keytool -exportcert -alias androiddebugkey -keystore c:\Users\<your windows default user>\.android\debug.keystore | openssl sha1 -binary | openssl base64
    

    Enter keystore password: android

    0 讨论(0)
  • 2020-12-14 13:39

    When having the error in the log, when trying to login to Facebook, look for something that looks like:

    Invalid key hash. The key hash *** does not match any stored key hashes. Configure your app key hashes at http://developers.facebook.com/apps/565561836797777
    

    where "***" is the key that you need to use.

    0 讨论(0)
  • 2020-12-14 13:40

    I had the same problem, I spend a couple of hours to find a solution, but actually the Facebook SDK provides the solution by itself.

    in the DialogListener class I modified the onFacebookError method:

    @Override 
    public void onFacebookError(FacebookError error) {
       Log.d("myTag",error.getmessage); 
     }
    

    Execute the app (which was sign with the same key i use for the market), and on LogCat will be a message under this tag with the correct key.

    We had also created a simple project which does all the work, and returns the correct key on an alert-box and on LogCat. You can find it on our blog.

    0 讨论(0)
  • 2020-12-14 13:50

    In eclipse, window -> preferences -> Android -> build -> default debug keystore, copy the path to replace the ~/.android/debug.keystore

    0 讨论(0)
  • 2020-12-14 13:53

    try

    try {
    PackageInfo info = getPackageManager().getPackageInfo("com.eatapp", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        Log.e("MY KEY HASH:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
    }
    } catch (NameNotFoundException e) {
    
    } catch (NoSuchAlgorithmException e) {
    
    }
    

    in your main Activity :-) This is the only solution it works for me for Android SDK 3.0

    0 讨论(0)
  • 2020-12-14 13:54

    keytool -exportcert -alias androiddebugkey -keystore "debug.keystore path" | openssl sha1 -binary | openssl base64

    if you haven't setup environment variables for open ssl and java sdk than put jdk's bin folder path in place of keytool and your openssl path in place of openssl and not to forget to put double quotes for your path

    ex-"C:\Program Files\Java\jdk1.5.0_11\bin" -exportcert -alias androiddebugkey -keystore "C:\Users\amin.android\debug.keystore" | "F:\openssl\binsha1\openssl.exe" -binary | "F:\openssl\binsha1\openssl.exe" base64

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