I have built a Facebook integration using the steps from the 3.0 documentation. It works fine in when I deploy the app to my phone using Eclispe; however, when I export the
If you are using Facebook SDK 4.x, then note that the package name changed. It's now com.facebook.login.widget.LoginButton
FacebookSdk.sdkInitialize(getApplicationContext());
this before setContentView
setContentView(R.layout.activity_home);
After add Facebook as a module you have to add it to your dependencies in Gradle, adding the next line into dependencies block:
compile project(':facebook')
I hope it can help.
just in case.. if some one still needs it, clean only the facebook project, and then add it back as a library in your project. This solved my problem
I tried Programatically creating instance of LoginButton programatically like
LoginButton loginButton = new LoginButton(this);
and added this to a LinearLayout
fbLoginButton = (LinearLayout) findViewById(R.id.fb_login_view);
fbLoginButton.addView(loginButton);
And here is the glimpse of my layout xml
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="40dip"
android:id="@+id/fb_login_view"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
android:text="connect_with_facebook"/>
This is ofcourse following the edit suggested by @Lalit Kumar's answer Let me know if I am missing anything.
The only way I found to fix this was to put the whole SDK into my project. Now it works. Not the prefered solution, but it works.