2

I did all steps from Android Facebook SDK 4 in Eclipse and https://developers.facebook.com/docs/android/getting-started#login_share

My activity:

public class MainActivity extends Activity {
    LoginButton loginButton;
    CallbackManager callbackManager;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        FacebookSdk.sdkInitialize(getApplicationContext());
        setContentView(R.layout.activity_main);
        callbackManager = CallbackManager.Factory.create();
        loginButton = (LoginButton) findViewById(R.id.login_button);
        loginButton.setReadPermissions("user_friends");


        // Callback registration
        loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                // App code
            }

            @Override
            public void onCancel() {
                // App code
            }

            @Override
            public void onError(FacebookException exception) {
                // App code
            }
        });    


        final Button but_nova_hra = (Button) findViewById(R.id.nova_hra);
        but_nova_hra.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent obrazovkaHry = new Intent(getApplicationContext(), HraActivity.class);
                startActivity(obrazovkaHry);
            }
        });

        final Button but_koniec = (Button) findViewById(R.id.konec);
        but_koniec.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                finish();
            }
        });
    }
}

App crashes during start with

Could not find com.facebook.FacebookActivity referenced from method com.facebook.internal.Validate.hasFacebookActivity

Where can the problem be?

Community
  • 1
  • 1
  • 1
    Duplicated question: http://stackoverflow.com/questions/30876049/android-facebook-login-button-crash – Pang Jun 17 '15 at 03:11

1 Answers1

1

the answer of that error is initialize the facebook SDK line before the set content view after the oncreate constuctor

Ahmed Nader
  • 151
  • 5
  • 19