Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

android - Facebook login button crash

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?

EDIT: Just created new blank app with completly same settings and FacebookSdk.sdkInitializing passed sucessfully. There have to be some problem with this specific application, but where ? Both of them have same settings ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I guess you need to declare FacebookActivity in your manifest file like this

<activity android:name="com.facebook.FacebookActivity"
          android:configChanges=
                 "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
          android:theme="@android:style/Theme.Translucent.NoTitleBar"
          android:label="@string/app_name" />

Its mentioned here..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...