App is misconfigured for Facebook login - not returning the logcat, after setting ENABLE_LOG to true in util.java

前端 未结 1 1151
执念已碎
执念已碎 2020-12-10 10:18

Sorry for asking the same question, but I read all the threads posted before and tried everything suggested, but I was still unsuccessful.

I am getting the same:

1条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-10 10:34

    Assuming you're using the latest 3.0 SDK, try the following two options:

    Option 1: (Windows)

    %KEYTOOLPATH%\keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | %OPENSSLPATH%\openssl sha1 -binary | %OPENSSLPATH%\openssl base64
    

    Example:

    C:\Program Files (x86)\Java\jdk1.7.0_09\bin\keytool" -exportcert -alias androiddebugkey -keystore "C:\Home\.android\debug.keystore" | "C:\OpenSSL\bin\openssl" sha1 -binary | "C:\OpenSSL\bin\openssl" base64 
    

    Use the password: android

    Option 2: (Print key hash sent to FB)

    (A variation of Facebook SDK for Android - Example app won't work)

    Add this code to your activity:

        try {
            PackageInfo info = getPackageManager().getPackageInfo("your package name, e.g. com.yourcompany.yourapp]", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
                }
        } catch (NameNotFoundException e) {
    
        } catch (NoSuchAlgorithmException e) {
    
        }
    

    Example: In HelloFacebookSampleActivity, make the following temporary modification to the onCreate() method

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            PackageInfo info = getPackageManager().getPackageInfo("com.facebook.samples.hellofacebook", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
                }
        } catch (NameNotFoundException e) {
    
        } catch (NoSuchAlgorithmException e) {
    
        }
    
        ...
    }
    

    Run your sample and you should get logcat output on the KeyHash tag similar to:

    12-20 10:47:37.747: D/KeyHash:(936): 478uEnKQV+fMQT8Dy4AKvHkYibo=
    

    Use that value in Facebook's App Dashboard settings for your app.

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