Error inflating class com.facebook.widget.LoginButton

前端 未结 14 2643
星月不相逢
星月不相逢 2020-12-15 06:54

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

相关标签:
14条回答
  • 2020-12-15 07:41

    you have to initialize facebook SDK before setContentView, so add following line right above the setContentView

    FacebookSdk.sdkInitialize(getApplicationContext());
    
    0 讨论(0)
  • 2020-12-15 07:41

    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
    
    0 讨论(0)
  • 2020-12-15 07:42

    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());
    }
    

    }

    0 讨论(0)
  • 2020-12-15 07:48

    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);
    }
    
    0 讨论(0)
  • 2020-12-15 07:50

    I had also same error and just by relacing android-support-v4.jar with android-support-v13.jar solved the problem.

    0 讨论(0)
  • 2020-12-15 07:50

    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.

    0 讨论(0)
提交回复
热议问题