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
you have to initialize facebook SDK before setContentView, so add following line right above the setContentView
FacebookSdk.sdkInitialize(getApplicationContext());
One solution is to add the path of the Facebook SDK to "project.properties" in your project.
Like:
android.library.reference.1=../libfacebook/facebook-android-sdk-3.0.1/facebook
Just initialize FacebookSdk.sdkInitialize(getApplicationContext()); in your Application class. Because Application class initializes even before your activities gets initialized.
do just like this :
public class ApplicationController extends Application{
@Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(getApplicationContext());
}
}
I was getting this error because I set the content view BEFORE sdkInitialize. The getting started guide has a comment referring to this.
https://developers.facebook.com/docs/android/getting-started#androidstudio
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
// Initialize the SDK before executing any other operations,
// especially, if you're using Facebook UI elements.
}
So my code now looks like this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FacebookSdk.sdkInitialize(getApplicationContext());
setContentView(R.layout.activity_main);
}
I had also same error and just by relacing android-support-v4.jar with android-support-v13.jar solved the problem.
If you add facebook library to your application at Properties->Android , you should delete facebook.jar in your facebooksdk path/bin/facebook.jar. It cause error when link in eclipse. Then you clean your facebook sdk and your application. I hope will work fine.