16

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
4

5 回答 5

26

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

  1. 右键单击项目
  2. 构建路径->配置构建路径
  3. 选项卡:订购和导出
  4. 确保检查了您的AndroidAndroid 依赖项
  5. 清理和构建您的项目

在我上次 ADT 更新期间,所有这些都未选中,并且我遇到了类似的错误。

于 2013-05-28T03:17:09.650 回答
0

make sure both actionbarsherlock and SherlockNavigationDrawer have the same (and latest) version of support library.

Right Click on Project > Android Tools > Add Support Library...

Do this for both projects and you're good to go ;)

于 2014-06-02T18:08:04.510 回答
0

我有一个类似的问题,以下步骤解决了我的问题:

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

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

就这样。

于 2015-03-07T10:36:31.683 回答
0

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

于 2016-10-17T16:00:29.447 回答
-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

我想这会解决你的问题

于 2015-02-06T17:52:41.387 回答