Android ClassNotFound and android.view.InflateException:

早过忘川 提交于 2019-12-01 08:54:28

There is no LoginButton in the main source of that SDK.
It's available in the sample code only, so it just fails to load the unavailable class (ClassNotFoundException)...

I also faced the same issue. I changed the main.xml from:

<com.facebook.android.LoginButton
    android:id="@+id/login"
    android:src="@drawable/login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_margin="30dp"
    />

to (Current package is com.facebook.fbtest_simple):

<com.facebook.fbtest_simple.LoginButton 
    android:id="@+id/login"
    android:src="@drawable/login_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_margin="30dp"
    />

As LoginButton is not part of FB standard library.

As of version 3.0 of the Facebook SDK, the LoginButton is now available as part of the SDK as com.facebook.widget.LoginButton

See https://developers.facebook.com/docs/reference/android/3.0/LoginButton

Note that Facebook's own upgrade instructions here reference the wrong package, the LoginButton must be declared as com.facebook.widget.LoginButton, not com.facebook.LoginButton

Easy one :

   10-14 00:58:37.786: ERROR/AndroidRuntime(3971): Caused by: java.lang.ClassNotFoundException: com.android.facebook.LoginButton in loader dalvik.system.PathClassLoader@44c06850

Looking for in the facebook src , you can go to this path:

AsyncFacebookRunner.java , Facebook.java, FacebookError.java , FbDialog.java, Util.java

..And see that there isn't nothing like LoginButton , then i can think that you are using an old tutorial or something like that.

Hector C

Initializing the Facebook SDK is what worked for me.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FacebookSdk.sdkInitialize(this.getApplicationContext());
    setContentView(R.layout.activity_login);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!