java android.support.v4.widget.DrawerLayout 未找到

2022-09-03 05:48:13

android.support.v4.widget.DrawerLayout;当我测试应用程序时,在我的手机上找不到。为什么会发生这种情况,我该如何修复它?

我还不知道,但我认为我可能有同样的问题,如果他们确实导致任何问题。android.support.v4.view.GravityCompat;android.support.v4.app.ActionBarDrawerToggle;

我以前从未遇到过任何问题,但现在它不起作用了。我有android.support.v4 lib(五月一个)。android.support.v4.*;

编辑:更好的错误消息

我的错误

05-27 19:46:21.230: E/jdwp(11659): Failed sending reply to debugger: Broken pipe
05-27 19:46:21.290: W/dalvikvm(11659): VFY: unable to resolve virtual method 30: Landroid/support/v4/widget/DrawerLayout;.closeDrawer (Landroid/view/View;)V
05-27 19:46:21.290: W/dalvikvm(11659): VFY: unable to resolve virtual method 27: Landroid/support/v4/app/ActionBarDrawerToggle;.onConfigurationChanged (Landroid/content/res/Configuration;)V
05-27 19:46:21.290: E/dalvikvm(11659): Could not find class 'android.support.v4.widget.DrawerLayout', referenced from method com.MainActivity.onCreate
05-27 19:46:21.290: W/dalvikvm(11659): VFY: unable to resolve check-cast 16 (Landroid/support/v4/widget/DrawerLayout;) in Lcom/MainActivity;
05-27 19:46:21.290: W/dalvikvm(11659): VFY: unable to resolve virtual method 28: Landroid/support/v4/app/ActionBarDrawerToggle;.onOptionsItemSelected (Landroid/view/MenuItem;)Z
05-27 19:46:21.290: W/dalvikvm(11659): VFY: unable to resolve virtual method 29: Landroid/support/v4/app/ActionBarDrawerToggle;.syncState ()V
05-27 19:46:21.290: W/dalvikvm(11659): VFY: unable to resolve virtual method 31: Landroid/support/v4/widget/DrawerLayout;.isDrawerOpen (Landroid/view/View;)Z
05-27 19:46:21.290: W/dalvikvm(11659): Unable to resolve superclass of Lcom/MainActivity$1; (14)
05-27 19:46:21.290: W/dalvikvm(11659): Link of class 'Lcom/MainActivity$1;' failed
05-27 19:46:21.340: W/dalvikvm(11659): threadid=1: thread exiting with uncaught exception (group=0x40bc71f8)
05-27 19:16:42.404: E/dalvikvm(10623): Could not find class 'android.support.v4.widget.DrawerLayout', referenced from method com.MainActivity.onCreate
05-27 19:16:42.464: E/AndroidRuntime(10623): FATAL EXCEPTION: main
05-27 19:16:42.464: E/AndroidRuntime(10623): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.MainActivity}: android.view.InflateException: Binary XML file line #3: Error inflating class android.support.v4.widget.DrawerLayout

答案 1

如果您最近更新了 ADT,则您的库构建路径可能已损坏。请尝试以下操作:

  1. 右键单击“项目”
  2. 构建路径 -> 配置构建路径
  3. 选项卡:订购和导出
  4. 确保您的安卓安卓依赖关系库已被选中
  5. 清理和构建你的项目

在我上次ADT更新期间,所有这些都变得不受检查,我也有类似的错误。


答案 2

确保 actionbarsherlockSherlockNavigationDrawer 都具有相同(和最新)版本的支持库。

右键单击项目>安卓工具>添加支持库...

这两个项目执行此操作,您就可以;)