Session.StatusCallback cannot be resolved to a type - Facebook API

10,417

Solution 1

I had the same problem as your first one, and I solved it by removing

import android.service.textservice.SpellCheckerService.Session;

and adding

import com.facebook.Session;

Solution 2

I had a similar issue, and the problem was that I had these two imports in the file

import android.app.DownloadManager.Request;
import android.service.textservice.SpellCheckerService.Session;

And those Request and Session modules were overriding

com.facebook.Session
com.facebook.Request

I actually just removed the two android imports and everything worked nicely. They didn't seem to be used, but eclipse added them in for some strange reason.

Judging by your output

The method executeAsync() is undefined for the type DownloadManager.Request

I'd say it sounds like you have the same imports happening somewhere and they're overriding the facebook imports.

Solution 3

Got this issue when having both Request and Session classes from Volley framework already imported. Try using the class with the package name for Session and Request, it worked for me. See below's code.

private com.facebook.Session.StatusCallback callback = 
    new com.facebook.Session.StatusCallback()
{
    @Override
    public void call(com.facebook.Session session, 
            SessionState state, Exception exception) {
        onSessionStateChange(session, state, exception);
    }
};

Solution 4

For your first problem, which import do you use ? I use this for the Callback:

import com.facebook.Session.StatusCallback;

Which Facebook SDK are you using ? The newest one ? I am using latest sdk 4.01 butin this sdk is not support this pakage

Share:
10,417
Rucha Heda
Author by

Rucha Heda

Updated on June 09, 2022

Comments

  • Rucha Heda
    Rucha Heda almost 2 years

    I followed the login authentication tutorial on Facebook and have copied the following code into my android application

    private Session.StatusCallback callback = 
        new Session.StatusCallback()
    {
        @Override
        public void call(Session session, 
                SessionState state, Exception exception) {
            onSessionStateChange(session, state, exception);
        }
    };
    

    However, it is giving me the following errors:

    Session.StatusCallback cannot be resolved to a type
    

    Which is leading to the following errors:

    callback cannot be resolved to a variable
    

    There's also other places where Facebook API calls are made that are giving me errors, but it's not in all the Facebook API calls. Another place I'm getting an error is the following:

    Request request = Request.newMeRequest(session, 
                        new Request.GraphUserCallback() {
                    @Override
                    public void onCompleted(GraphUser user, Response response) {
                        // If the response is successful
                        if (session == Session.getActiveSession()) {
                            if (user != null) {
                                // Set the id for the ProfilePictureView
                                // view that in turn displays the profile picture.
                                Log.d("MainActivity", "onComplete() User logged in");
                                parent.owner = MainKickback.userConnection.add(new User(user.getId()));
    
                                EventFragment e = (EventFragment) fragments[UPCOMING_EVENTS];
                                e.populateEvents();
                            }
                        }
                        if (response.getError() != null) {
                            // Handle errors, will do so later.
                        }
                    }
                });
                request.executeAsync();
    

    where it does not recognize Request.GraphUserCallback, and then executeAsync(). I get the following errors:

    Request.GraphUserCallback cannot be resolved to a type
    The method executeAsync() is undefined for the type DownloadManager.Request
    

    Does anyone have any advice as to how to fix this?

    Thank you for your help in advance!!

  • Rucha Heda
    Rucha Heda almost 11 years
    I am using import com.facebook.SessionState; and importing anything else gives me a conflict. And I am using Facebook SDK 3.0.1 i think
  • Luser_k
    Luser_k almost 11 years
    Hmmm silly question but, did you imported the facebook sdk as an android project and included that into your buildpath of your project as a library project ?
  • Rucha Heda
    Rucha Heda almost 11 years
    Yes, I did. This entire project was working before, then I updated my git repo and things broke and now I'm trying to fix it again. Other calls to Facebook API are not throwing errors. But these particular ones are and I'm not sure why.
  • Darth Coder
    Darth Coder over 10 years
    You are a life saver!! Why do you think the SpellCheckerService.Session was creating a problem, because I had the exact same issue and it got solved by removing the statement!