Android ClassNotFound 和 android.view.InflateException:

2023-12-08

我正在尝试将 facebook 集成到我的应用程序中。我正在使用从以下位置下载的 facebook 示例应用程序facebook作为参考(还生成了appId以及所有这一切的过程开发者脸书)。我有点懒,所以我不想遍历 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 标准库的一部分。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android ClassNotFound 和 android.view.InflateException: 的相关文章

  • 由于现有相机用户,相机“0”的手电筒不可用

    我想创建一个应用程序 它有一个用于录制视频的按钮和另一个单独的切换按钮 用于在录制视频期间打开闪光灯 我已经使用camera2 API为最近的androids构建了相机应用程序 可以通过图像按钮访问 我将火炬模式设置为切换按钮 但这根本不起
  • 禁用 com.google.android.maps.MapView 中的平移/缩放

    如何禁用 MapView 的平移 缩放功能 不是缩放控件 我想要一个完全静态的地图 我还注意到触摸地图似乎不会触发 MapView onClickListener 有人可以详细说明为什么吗 对于 Android 版 Google Maps
  • animation.start() 或animation.startNow() 不会立即开始动画

    我有一个奇怪的问题 有时应该淡出我的控件 ImageButton 的动画不会立即启动 我使用淡出动画来隐藏它 然后在 myListener 的末尾 onAnimationEnd 中 我将新资源作为按钮上的图像 我的应用程序代码中的某处 An
  • 垂直 ViewPager 中的动画

    我需要垂直制作这个动画ViewPager https www youtube com watch v wuE 4jjnp3g https www youtube com watch v wuE 4jjnp3g 这是我到目前为止所尝试的 vi
  • 通过模拟器控制台或 ADB 更改 Android 模拟器方向

    我正在尝试构建一个自动化测试框架 用于检查应用程序应该响应的基本内容 而不会崩溃 其中之一是检查应用程序是否正确响应配置更改 现在 由于它是自动化的 我必须以编程方式在横向和纵向之间切换模拟器的方向 并观察它是否崩溃 大写 因为有很多与 c
  • Android:将声音保存为铃声/SQLiteConstraintException

    我正在尝试使用 Android 将声音保存为铃声this http www stealthcopter com blog 2010 01 android saving a sound file to sd from resource and
  • Android 和 Honeycomb - 如何使用 SDK 13 拥有菜单图标而不需要“操作栏”

    我想最大限度地利用 Honeycomb 应用程序的屏幕 由于屏幕底部已经被 始终打开 的项目所困 我想在该空间中添加一个菜单按钮 而不是牺牲更多的屏幕空间 在顶部放置一个 操作栏 我怎样才能做到这一点without降级到 API 10 或更
  • 改造将多个图像上传到单个密钥

    我正在使用 Retrofit 将图像上传到我的服务器 这里我需要为一个密钥上传多个图像 我已经尝试使用 Postman 网络客户端 它运行良好 这是一个屏幕截图 以下是请求的键值对 调查图像 文件1 文件2 文件3 属性图像 文件DRA j
  • webview 中的 android 移动 Twitter 页面无法打开?

    我正在尝试打开以 https 开头的 Twitter 页面webview在安卓中 但它没有打开 并且持续加载时出现黑屏 屏幕截图如下 Edit 在主网络视图中我有 Twitter 页面的链接https twitter com mytwitt
  • 作为 ViewPager 的一部分更新 ListFragment 中的数据

    我在 Android 中使用 v4 兼容性 ViewPager 我的 FragmentActivity 有一堆数据 这些数据将以不同的方式显示在我的 ViewPager 的不同页面上 到目前为止 我只有同一个 ListFragment 的
  • 如何在 Eclipse 中获得完全限定的类名?

    有没有一种快速方法可以在 Eclipse 中单击 Java 类并获取其完全限定名称 或将其复制到剪贴板 2016年6月29日编辑 正如 Jeff 所指出的 您只需要执行以下第二步 1 Double click on the class na
  • 如何告诉 OkHttpClient 忽略缓存并强制从服务器刷新?

    在我的 Android 应用程序中 我将 Retrofit 与 OkHttpClient 结合使用 并启用缓存来访问某些 API 我们的一些 API 有时会返回空数据 我们在应用程序中提供了一个 刷新 按钮 供客户端从特定 API 重新加载
  • 如何在移动应用程序上连接到服务器?

    我是移动应用程序的新手 我基本上来自网络开发平台 我只是在玩 App Framework LungoJS Jquery Mobile kendo 等移动框架 以获得该垂直领域的一些知识 我正在开发的应用程序仍然处于 UI 级别 我所需要的只
  • 如何在 LazyColumn 底部添加空白区域?

    我想添加 LazyColumn 的空白底部 并且我想允许用户调出底部元素 我怎样才能实现这个 Example LazyColumn modifier Modifier fillMaxWidth height 300 dp border 2
  • Facebook 登录打开错误的应用程序

    我正在尝试使用 facebook 实现应用程序的登录 但每次我尝试登录时 它都建议打开错误的应用程序 我尝试了一些在这里找到的东西 但没有成功 在 Facebook 的开发者页面上我添加了一个后缀 我的 plist 如下 有谁知道发生了什么
  • 通过 Google 帐户从 Google Play 安装的应用程序列表

    以下是我的问题 是否可以通过使用任何 api 以编程方式通过 Google Play 获取用户已安装的应用程序列表 请注意 我并不是询问设备中当前安装的应用程序列表 而是询问在某个时刻已安装的应用程序列表 我需要解决上述问题 因为我正在考虑
  • Firebase:用户注册后如何进行电话号码验证?

    所以我知道我可以使用电子邮件验证或电话号码验证 但我想做的是在用户注册或登录后进行电话号码验证 如何连接这两种身份验证方法 最后 Firebase中是否有一个函数可以检查用户是否通过电话号码验证 谢谢 即使用户已通过身份验证 您仍然可以使用
  • 从 Dropbox 下载文件并将其保存到 SDCARD

    现在我真的很沮丧 我想从 Dropbox 下载一个文件并将该文件保存到 SD 卡中 我得到的代码为 private boolean downloadDropboxFile String dbPath File localFile throw
  • PhoneGap Build Android 不显示闪屏

    这是我的 config xml 中与启动屏幕相关的代码
  • 连接到具有相同 SSID 的最强接入点(信号最强的接入点)

    我正在编写一个程序来始终连接到最强的接入点 我的意思是信号最强的接入点 首先 我扫描所有可用的 WiFi 网络 然后限制它们仅查看具有相同 SSID 的网络 这样我就可以看到一个网络的所有AP 当我连接到该网络时 它没有连接到最强的信号 但

随机推荐