Error inflating class com.facebook.widget.LoginButton

前端 未结 14 2641
星月不相逢
星月不相逢 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:28

    If you are using Facebook SDK 4.x, then note that the package name changed. It's now com.facebook.login.widget.LoginButton

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

    FacebookSdk.sdkInitialize(getApplicationContext());

    this before setContentView

      setContentView(R.layout.activity_home);
    
    0 讨论(0)
  • 2020-12-15 07:30

    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.

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

    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

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

    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.

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

    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.

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