Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

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

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:

App is misconfigured for Facebook login.

Screen shot

The issue looks same as here, but I could not get the Logcat printed as an error in red even after setting ENABLE_LOG to true in util.java.

I have checked my app_id and copied the hash key in developer.facebook, and everything looks right. But I don't know where I am going wrong and also that I am getting it right when I use the app without native Facebook app.

But I want to login using native Facebook.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Option 1: (Windows)

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

Example:

C:Program Files (x86)Javajdk1.7.0_09inkeytool" -exportcert -alias androiddebugkey -keystore "C:Home.androiddebug.keystore" | "C:OpenSSLinopenssl" sha1 -binary | "C:OpenSSLinopenssl" 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...