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

时间:2013-05-28 02:33:12

标签: java android xml layout

我测试应用时手机上找不到

android.support.v4.widget.DrawerLayout;。为什么会发生这种情况?如何解决?

我还不知道,但我想我可能遇到android.support.v4.view.GravityCompat;同样的问题 和android.support.v4.app.ActionBarDrawerToggle;如果确实造成任何问题。

我之前从未遇到android.support.v4.*;任何问题,但现在它无法正常工作。 我有android.support.v4 lib(可能是一个)。

编辑:更好的错误消息

我的错误

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

5 个答案:

答案 0 :(得分:26)

如果您最近更新了ADT,那么您的库构建路径可能已经搞砸了。请尝试以下方法:

  1. 右键单击Project
  2. 构建路径 - > 配置构建路径
  3. 标签:订单和导出
  4. 确保已检查 Android Android Dependencies
  5. 清洁&建立您的项目
  6. 在我上次的ADT更新期间,所有这些都未经检查,我也遇到了类似的错误。

答案 1 :(得分:0)

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

右键单击Project> Android工具>添加支持库...

两个项目做这件事,你很高兴;)

答案 2 :(得分:0)

我遇到了类似的问题,以下步骤解决了我的问题:

  1. 我在库项目FacebookSDK中打开了project.properties并检查了目标,在我的例子中是target = android-10。

  2. 转到SDK管理器并检查是否安装了API 10,如果缺少则安装。

  3. 多数人。

答案 3 :(得分:0)

我的解决方案(适用于Eclipse):
在[Project-Name] / libs目录中复制正确版本的支持库 也许你必须重建项目 PS:支持库位于[Your-SDK-Directory] ​​/ [Choosen-SDK] / extras / android / support / [v4 | v9 | v13] / src

答案 4 :(得分:-1)

是的,我已经解决了你的问题 只是

Right click on Project
Build Path -> Configure Build Path
add your external support v4 
then check the support v4 from order and export

Make sure your Android and Android Dependencies libraries are checked
Clean & Build your Project

我认为这将解决您的问题