简体   繁体   中英

Android LoginButton: An error occurred.Please try again later(Invalid Application ID: The provided Application ID is invalid.)

I made a demo following the tutorial " Use Facebook Login ".

I have setted this code in MainFragment:

LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
authButton.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status"));

I encountered an error when logging in with second account. I meant that I logged in successfully with another account before. Then I logged out, and tried to log in with second account.

It showed an error dialog that showed the message, "An error occurred. Please try again later," with the title "Error" and an "Okay" button on the right.

I tried to see the error add the below code.I got it,but I still didn't understand how to do now.

authButton.setOnErrorListener(new OnErrorListener() {
        @Override
        public void onError(FacebookException error) {
            Log.e("test", "error: "+error.getMessage());
        }
    });

It show:

error: kError 1349040: Invalid Application ID: The provided Application ID is invalid.

But when I tried to log in with the account before, it was successful again.

Before this error,I have encountered this error:

remote_app_id does not match stored id

I changed the key hash in setting as the " Getting Started with the Facebook SDK for Android " recommended. Add the code:

 // Add code to print out the key hash
    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) {

    }

so that it logged in successful.

Also,I tried to use the release key and sign my apk.The result is same.one account can ,another can not.

Now,these day ,I tried again.the error disappeared.Only show a white dialog with nothing only a delete button on the left top.

Note: I use Facebook SDK for Android V3.01.

[Problem Resolved]

Two factors led to this problem.

Firstly,it's my Openssl utility is wrong.Then I download it from the doc recommended in Use Facebook Login

Secondly, The sandbox is checked by default.I unchecked the sandbox mode in dashboard as Anton Roy said in the answer.

have you unchecked the sandbox mod on your facebook application ?

it's enabled by default, i had the same problem as you and it has resolved my issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM