16

android.support.v4.widget.DrawerLayout; is not being found on my phone when I test the app. why is this happening and how do I fix it?

I don't know yet but I think I may be having the same problem with android.support.v4.view.GravityCompat; and android.support.v4.app.ActionBarDrawerToggle; if they do cause any problems.

I have never had any problems with android.support.v4.*; before but now it's not working. I have android.support.v4 lib (the may one).

Edit: better error message

my error

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
Falko
  • 17,076
  • 13
  • 60
  • 105
Spik330
  • 502
  • 4
  • 6
  • 19
  • The problem is in the xml layout that you set for content view. You need to post the xml. – Neoh May 28 '13 at 02:34
  • I tried googles code after mine to see if I could get it to work so I loaded their source code and I still got an error. http://developer.android.com/training/implementing-navigation/nav-drawer.html – Spik330 May 28 '13 at 02:39
  • Have you updated to the latest support library version also? – Neoh May 28 '13 at 02:44
  • Please post your XML. Otherwise it's difficult to help you. – Daniel Lerps May 28 '13 at 03:10

5 Answers5

26

If you recently updated your ADT your Library Build Paths might have been messed up. Try the following:

  1. Right click on Project
  2. Build Path -> Configure Build Path
  3. Tab: Order and Export
  4. Make sure your Android and Android Dependencies libraries are checked
  5. Clean & Build your Project

During my last ADT update all of them became unchecked and I had similar errors.

Daniel Lerps
  • 5,256
  • 3
  • 23
  • 33
  • build path is fine that's one of the first things I cheched – Spik330 May 28 '13 at 03:21
  • Another very similar problem I recently had was with the Google Play libraries which were not up to date after the ADT update. Have you checked the SDK tools if the support libraries need an update? – Daniel Lerps May 28 '13 at 03:26
  • did that to, I have went so far as to download the newest one from google – Spik330 May 28 '13 at 03:41
  • @DuffsMontgomary Have you got any fix for this issue. I'm too facing the same problem. – sachin003 May 29 '13 at 11:20
  • 11
    To add on to this.. For me I didn't have the support libraries. I tried private libraries and dependencies with no luck. What worked for me was right clicking the project and going to Android Tools > Add Support libraries... and that automatically updated and added the missing support libraries as a jar in the libs folder. Then I had to right click that jar and click "add to build path" THEN I could check the jar in Order & Export (as described in the answer above). Hope this helps someone. – Lenny Dec 12 '13 at 18:25
  • @Lenny thanks..you certainly saved me from my misery – user578386 Feb 25 '14 at 07:15
  • Don't forget to do clean!! – Navid Nov 25 '15 at 07:50
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 ;)

mmbrian
  • 1,672
  • 2
  • 14
  • 26
0

I had a similar problem, following steps solved my issue:

  1. I opened project.properties in library project FacebookSDK and checked the target, which in my case was target=android-10.

  2. go to SDK manager and check if API 10 is installed, install if its missing.

Thats all.

AamirR
  • 11,672
  • 4
  • 59
  • 73
0

My solution (for Eclipse):
Copy the right version of the Support Libraries in the [Project-Name]/libs directory.
Maybe you must rebuild the Project.
PS: The Support Libraries are under [Your-SDK-Directory]/[Choosen-SDK]/extras/android/support/[v4|v9|v13]/src

TobTobXX
  • 418
  • 4
  • 17
-1

yes i have solved your problem just

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

i think this will solve your problem

pavel_coder
  • 181
  • 2
  • 5
  • 5
    Where is `project` which I am supposed to right click on? I just updated to the latest version of Android Studio 1.2.1.1 – Zack May 17 '15 at 12:30