Shruti
Shruti

Reputation: 5591

While integrating FB Sdk in my app i get java.lang.classnotfoundexception

While integrating fb sdk in my application i get following error :

06-05 16:01:42.758: E/AndroidRuntime(892): FATAL EXCEPTION: main
06-05 16:01:42.758: E/AndroidRuntime(892): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.biz.fbapp/com.biz.fbapp.FBAppActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.facebook.android.LoginButton
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.os.Looper.loop(Looper.java:137)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.ActivityThread.main(ActivityThread.java:4424)
06-05 16:01:42.758: E/AndroidRuntime(892):  at java.lang.reflect.Method.invokeNative(Native Method)
06-05 16:01:42.758: E/AndroidRuntime(892):  at java.lang.reflect.Method.invoke(Method.java:511)
06-05 16:01:42.758: E/AndroidRuntime(892):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-05 16:01:42.758: E/AndroidRuntime(892):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-05 16:01:42.758: E/AndroidRuntime(892):  at dalvik.system.NativeStart.main(Native Method)
06-05 16:01:42.758: E/AndroidRuntime(892): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.facebook.android.LoginButton
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-05 16:01:42.758: E/AndroidRuntime(892):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.Activity.setContentView(Activity.java:1835)
06-05 16:01:42.758: E/AndroidRuntime(892):  at com.biz.fbapp.FBAppActivity.onCreate(FBAppActivity.java:53)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.Activity.performCreate(Activity.java:4465)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
06-05 16:01:42.758: E/AndroidRuntime(892):  ... 11 more
06-05 16:01:42.758: E/AndroidRuntime(892): Caused by: java.lang.ClassNotFoundException: com.facebook.android.LoginButton
06-05 16:01:42.758: E/AndroidRuntime(892):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-05 16:01:42.758: E/AndroidRuntime(892):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-05 16:01:42.758: E/AndroidRuntime(892):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.view.LayoutInflater.createView(LayoutInflater.java:552)
06-05 16:01:42.758: E/AndroidRuntime(892):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
06-05 16:01:42.758: E/AndroidRuntime(892):  ... 21 more

on this line

setContentView(R.layout.main);

code on main.xml is

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="@drawable/white"
    android:gravity="center_horizontal">

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

    <TextView android:id="@+id/txt" 
        android:text="@string/hello"
        android:textColor="@drawable/black"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

    <Button android:id="@+id/uploadButton"
        android:text="@string/upload"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:paddingRight="20dp" 
        android:paddingLeft="20dp"
        android:layout_margin="20dp" 
        />

    <Button android:id="@+id/requestButton"
        android:text="@string/request"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:paddingRight="20dp" 
        android:paddingLeft="20dp"
        android:layout_margin="20dp" 
        />


    <Button android:id="@+id/postButton" 
        android:text="@string/post"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:paddingRight="20dp" 
        android:paddingLeft="20dp"
        android:layout_margin="20dp" 
        />

    <Button android:id="@+id/deletePostButton" 
        android:text="@string/delete"
        android:visibility="invisible"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:paddingRight="20dp" 
        android:paddingLeft="20dp"
        android:layout_margin="20dp" 
        />



</LinearLayout>

Please help me by telling what I have missed or done wrong.

Edit :

Now I get noclassdeffound even after i imported that file, unable to add library on that specific project..

Thanks Shruti

Upvotes: 1

Views: 1743

Answers (3)

Anton I. Sipos
Anton I. Sipos

Reputation: 3613

See also this question: Android ClassNotFound and android.view.InflateException:

I've copied my answer from there:

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 here.

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

Upvotes: 2

Tarun
Tarun

Reputation: 13808

There are examples in the downloaded facebook sdk. Use the example files from any of the examples

path_to_facebook_sdk/examples/simple/src/com/facebook/android/LoginButton.java

Import the above file in your project.

Upvotes: 0

Vipul
Vipul

Reputation: 28093

Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.facebook.android.LoginButton

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)

Upvotes: 1

Related Questions