gpt4 book ai didi

Android ClassNotFound 和 android.view.InflateException :

转载 作者:太空宇宙 更新时间:2023-11-03 11:52:48 25 4
gpt4 key购买 nike

我正在尝试将 facebook 集成到我的应用程序中。我正在使用从 facebook 下载的 facebook 示例应用程序作为引用(还生成了 appIddeveloper.facebook 上的所有过程)。我有点懒,所以我不想浏览 facebook sdk 的所有代码。简单来说,我只是添加我的应用程序中的 com_android_facebook 库项目,并将 facebook 示例应用程序中的所有类复制到我的应用程序中,Example.java 除外

现在我将 MyActivity 类修改为 Example.java 类,这意味着 MyActivity 现在拥有 Example 类的所有代码以及我的主要 Activity。

然后我将应用的布局更改为

    <?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>

现在当我运行我的应用程序时出现错误

   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

欢迎任何帮助和建议...

最佳答案

我也遇到了同样的问题。我将 main.xml 更改为:

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

到(当前包是 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"
/>

因为 LoginButton 不是 FB 标准库的一部分。

关于Android ClassNotFound 和 android.view.InflateException :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7759882/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com