51

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);
}
bjb568
  • 11,089
  • 11
  • 50
  • 71
Rom Freiman
  • 541
  • 1
  • 4
  • 6
  • 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 04 '12 at 15:04

7 Answers7

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.

Vinay S Shenoy
  • 4,028
  • 3
  • 31
  • 36
  • 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? – Rom Freiman Oct 01 '12 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? – Rom Freiman Oct 01 '12 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. – Vinay S Shenoy Oct 01 '12 at 12:15
  • Attached above. Thanks in advance – Rom Freiman Oct 01 '12 at 13:14
  • Two things. Print the errors that come in the DialogListener() of your facebook.authorize() method to make sure the call is being made. Second, have you overriden the onActivityResult() method of your activity to authorize the callback? – Vinay S Shenoy Oct 01 '12 at 13:21
  • Have you overridden the onActivityResult() of your activity? You have to do it for the Facebook authorize call to return. – Vinay S Shenoy Oct 01 '12 at 13:45
  • 1. It seems that the code does not arrive the onComplete func of authorize. 2. I have the onActivityResult(). 3. I got Webpage no available (http://touch.facebook.com/auth.php? Any ideas? – Rom Freiman Oct 01 '12 at 14:23
  • Let's go through a checklist of common possible errors.. 1. Have you given the INTERNET permission in your Manifest? 2. Have you initialized the Facebook object properly? Use facebook.getAppId() to print the App Id and check that. 3. Also post the place where you're initializing your facebook object 4. Also, don't use 0 as a default value for access token expiry. It means that the access token never expires. Use 1 instead. – Vinay S Shenoy Oct 01 '12 at 14:31
  • 1. yes, getAppId prints the correct APP_ID - just before perform authorize. 3. Singelton.mFacebook = new Facebook("273337169435401"); Singelton.mAsyncRunner = new AsyncFacebookRunner(Singelton.mFacebook); – Rom Freiman Oct 01 '12 at 15:41
  • I actually have no idea what could be the problem then... The app refuses to authorize on the emulator, right? – Vinay S Shenoy Oct 01 '12 at 15:50
  • 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. – Rom Freiman Oct 01 '12 at 16:03
  • @Vinay I installed FB on my phone as per your suggestion, but then the sample apps of the FB sdk started throwing the following error: "sample is misconfigured for Facebook login. Press Okay to go back to the application without connecting it to Facebook." – IgorGanapolsky Nov 05 '12 at 19:56
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
Jraco11
  • 4,526
  • 3
  • 20
  • 20
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;
}
vrunoa
  • 766
  • 8
  • 15
  • 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 '14 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 '14 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 =)

Penzzz
  • 2,814
  • 17
  • 23
0

Simply add the following permission to the AndroidManifest.xml

<uses-permission android:name="android.permission.SET_DEBUG_APP"/>
M.ES
  • 920
  • 14
  • 30
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...

Adrien V
  • 574
  • 4
  • 7
-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

Jake1164
  • 12,291
  • 6
  • 47
  • 64
Hemanth
  • 7
  • 1