52

Anyone knows what does this error mean? I get it in LogCat shell every time I connect with my android application to Facebook (via emulator).

The code which in charge of authorize functionality:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.authorize);
    mPrefs = getPreferences(MODE_PRIVATE);
    loginPref = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    String access_token = mPrefs.getString("access_token", null);
    long expires = mPrefs.getLong("access_expires", 0);
    if(access_token != null) {
        Singelton.mFacebook.setAccessToken(access_token);
    }
    if(expires != 0) {
        Singelton.mFacebook.setAccessExpires(expires);
    }

    Singelton.mFacebook.authorize(this, new String[] {"email","user_birthday"}, new DialogListener() {
        @Override
        public void onComplete(Bundle values) {
            SharedPreferences.Editor editor = mPrefs.edit();
            editor.putString("access_token", Singelton.mFacebook.getAccessToken());
            editor.putLong("access_expires", Singelton.mFacebook.getAccessExpires());
            editor.commit();
            SharedPreferences.Editor logEditor = loginPref.edit();
            logEditor.putBoolean("login", true);
            logEditor.commit();
            addUser();
        }

        @Override
        public void onFacebookError(FacebookError error) {
            errorHandler();
        }

        @Override
        public void onError(DialogError e) {
            errorHandler();
        }

        @Override
        public void onCancel() {
            Log.d("MyApp", "Facebook cancel");
        }
    });

}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Singelton.mFacebook.authorizeCallback(requestCode, resultCode, data);
}
1
  • I get this error but the authentication works anyway... According to the source code, it is for app install conversion tracking, so I wouldn't worry about it too much.
    – Timmmm
    Oct 4, 2012 at 15:04

7 Answers 7

44

It just means that you don't have the Facebook app installed on your phone. Don't worry too much about it.

The way the Facebook SDK for Android works is that whenever you need to make a request to Facebook, the SDK checks to see if the Facebook app is already installed on your device. If it is installed, the request is made through the app. If the app is not installed, it fetches the data by itself.

12
  • 6
    But I do have the Facebook app installed (thorough adb install). Also I have a problem to login to Facebook with the emulator - its just stuck on facebook empty page (on galaxy S the same code works fine). What can be the problem? Oct 1, 2012 at 11:33
  • I'm not sure it's the code - when I force the login without SSO (mFacebook.FORCE_DIALOG_AUTH in authorize), it does work. May be it some problem with facebook app on android emulator? Oct 1, 2012 at 12:13
  • No, I have used it without any problem. Again, if you can add the code of your LoginActivity to your question, we can see what the problem is and help you out. Oct 1, 2012 at 12:15
  • Attached above. Thanks in advance Oct 1, 2012 at 13:14
  • 1
    yep :( Although I solved the original problem - after installing newer version of facebook app, the katana error disappears. When I set incorrect API key, I get an error, but when I send the correct one, I just got an empty facebook - and never return to on complete of authorize. Oct 1, 2012 at 16:03
4

If anyone's problem wasn't remedied by the four solutions, this may help. I was getting this same error when I began to use Fragments to implement the Facebook login. I was using the standard Fragment and not the support library v4 Fragments and after switching to the support library Fragment my problem went away. This may be unique to my situation but thought I'd share it just in case. Also don't forget to set the Fragment if you're using the login button method.

myFacebookLoginButton.setFragment(this); //Assuming you're in a Fragment class
1

As @Vinay-S-Shenoy said, that happens when the Facebook app its not installed on the phone or the simulator. What I do, to avoid this error is to check if the Facebook app its installed before call the facebook.authorize method, an in case the facebook app its not installed I alert this message to the user.

public boolean isFacebookAvailable() {

    Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Test; please ignore");
intent.setType("text/plain");

    final PackageManager pm = this.getApplicationContext().getPackageManager();
    for(ResolveInfo resolveInfo: pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY)){
        ActivityInfo activity = resolveInfo.activityInfo;
        // Log.i("actividad ->", activity.name);
        if (activity.name.contains("com.facebook.katana")) {
            return true;
        }
    }
    return false;
}
2
  • 3
    This is deprecated, you shouldn't use it!!!! The new sdk checks if the apps its installed, and if it is not installed use a webview to login. So, don't use this solution.
    – vrunoa
    May 13, 2014 at 23:43
  • @242Eld I believe 3.1 already has the webview login(register) functionality. We have to implement this code on an app with fb sdk 3.0
    – vrunoa
    May 15, 2014 at 15:48
1

Don't forget to override onActivityResult and check if it called(for example if you using fragments)

PS(maybe it will be usefull for others, i faced this trouble when was using parse facebook login =)

0

Simply add the following permission to the AndroidManifest.xml

<uses-permission android:name="android.permission.SET_DEBUG_APP"/>
0

For me (but I work with ionic) it was because of an image missed / template error, before launch :

ionic cordova build android

Maybe it can help others...

-7
btnFb_photo_post.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        // postPhotoToWall(facebook.getAccessToken());
        facebook.authorize(MyFBTestActivity.this,
            new String[] { "publish_stream" },
            new DialogListener() {
                @Override
                public void onFacebookError(FacebookError e) {
                    // TODO Auto-generated method stub
                    Toast.makeText(getApplicationContext(),
                    e.getMessage(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void onError(DialogError dialogError) {
                    // TODO Auto-generated method stub
                    Toast.makeText(getApplicationContext(),
                    dialogError.getMessage(),
                    Toast.LENGTH_LONG).show();
                }

                @Override
                public void onComplete(Bundle values) {
                    postToWall(values.getString(Facebook.TOKEN));
                }

                private void postToWall(String accessToken) {
                    // Toast.makeText(getApplicationContext(),
                    // "trying", Toast.LENGTH_LONG).show();
                    byte[] data = null;
                    Bitmap bi = BitmapFactory.decodeResource(
                        getResources(), 
                        R.drawable.ic_launcher
                    );
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                    data = baos.toByteArray();
                    Bundle params = new Bundle();
                    // if (facebook.getAccessToken() != null)
                    params.putString(Facebook.TOKEN,
                        facebook.getAccessToken()
                    );

                    params.putString("method", "photos.upload");
                    params.putString("caption", "www.samplelink.com");
                    // params.putString("message",
                    // "www.google.com");

                    params.putByteArray("picture", data);
                    AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
                    mAsyncRunner.request(null, params, "POST",
                        new SampleUploadListener(), null);
                    }

                    @Override
                    public void onCancel() {
                        // TODO Auto-generated method stub
                    }
                }
            );
        }
    });

i am using this code to upload image to FB wall. try once

1
  • 14
    Please explain how this answers the question
    – CocoNess
    Oct 1, 2012 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.