Android的ClassNotFound的和android.view.InflateException:ClassNotFound、Android、android、InflateException

2023-09-06 17:18:29 作者:自找的痛不敢喊痛

我米试图整合在我app.I Facebook的正在使用从的Facebook下载Facebook的示例应用程序作为参考(还生成了的appid 而这一切的过程上的 developer.facebook )。我是小懒,所以我不希望通过Facebook的sdk.In简单的话所有的code我只是添加 com_android_facebook 在我的应用程序库项目,也复制所有的类Facebook的示例应用程序在我的应用程序,除了Example.java

I m trying to integrate the facebook in my app.I am using facebook example app downloaded from facebook as a reference(also generated the appId and all this process on developer.facebook).I am little lazy so I do not want to go through all the code of facebook sdk.In simple words i just add the com_android_facebook library project in my app, and also copy all the classes in facebook example app in my app except Example.java

现在我修改MyActivity类的样子Example.java级,意味着MyActivity现在有实例类的所有code,也是我的主要活动。

Now i modify the MyActivity class look like Example.java class, means MyActivity now have all the code of Example class and also my main Activity.

和我改变我的应用程序的布局

and i change the layout of my app as

    <?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout

   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   xmlns:android="http://schemas.android.com/apk/res/android"
  >
  <TextView
    android:id="@+id/text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true"
    android:textSize="22px"
    android:textColor="#ff00ff"
    android:gravity="center"
 >
  </TextView>

<com.android.facebook.LoginButton
 android:id="@+id/login"
 android:src="@drawable/login"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:layout_alignParentBottom="true"
/>

                      

<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" 
    />

</RelativeLayout>

现在,当我跑我的应用程序,我到达那里的错误

Now when i run my app i am getting there errors

   10-14 00:58:37.786: ERROR/AndroidRuntime(3971): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.myapp/com.android.myapp.MyActivity}: android.view.InflateException: Binary XML file line #21: Error inflating class com.android.facebook.LoginButton
   10-14 00:58:37.786: ERROR/AndroidRuntime(3971): Caused by: android.view.InflateException: Binary XML file line #21: Error inflating class com.android.facebook.LoginButton
   10-14 00:58:37.786: ERROR/AndroidRuntime(3971): Caused by: java.lang.ClassNotFoundException: com.android.facebook.LoginButton in loader dalvik.system.PathClassLoader@44c06850

任何帮助,建议者居多......

Any help, suggestions are most welcome...

推荐答案

没有 LoginButton 在SDK的主要来源。 这是样品$ C $只有c可用,所以它只是无法加载不可用类( ClassNotFoundException的

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