13

I'm trying to implement the Navigation Drawer as shown here: http://developer.android.com/training/implementing-navigation/nav-drawer.html#top

My code seems to be ok, and My minimum and target levels in my manifest match the example, but it's telling me it can't find the following three references

import android.support.v4.app.ActionBarDrawerToggle;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;

enter image description here

enter image description here

Jhorra
  • 6,233
  • 21
  • 69
  • 123
  • If you've already got an older copy of android-support-v4.jar in your libs/ directory of your project, you need to manually copy the new version over the top of it. The SDK Manager won't do that for you. – Squonk Jun 08 '13 at 00:16
  • Check my answer if you still have problem. – Jaydipsinh Zala Nov 16 '13 at 07:01

3 Answers3

20

May be you have found your answer but i think its for those who still wants to know. so, here's my answer,

For Android Studio:

First of all you need to add External Jar

  • In android studio go to File-> Project Structure -> Modules -> Dependencies -> + symbol -> Library Dependency.
  • Now search for support library. you will find something like this com.android.support:support-v13
  • Now, select Jar file named support-v13 (Whatever the version is) and click OK.

Now, you will see, no more errors like this.

For Eclipse:

Refer this link, Click here

Community
  • 1
  • 1
Jaydipsinh Zala
  • 16,558
  • 7
  • 41
  • 45
  • That fixed it for me. I had added the dependency manually to the gradle file before which did not work. So something else must be happening when adding the dependency via menu. Thanks :) – matthias krull Apr 20 '14 at 11:37
  • Thank you for that answer. I know this is a bit old, but do you know why Android Studio doesn't do this automatically? – Mo2 May 29 '14 at 02:57
  • Android studio makes it even easier now. When you go to click `+` you will see "Library Dependency" click that and it will show you a menu with the support files. – user1971 Aug 14 '14 at 13:47
  • @user1971 is correct in Android Studio goto File --> Project Structure --> Modules --> app --> Dependencies --> Click + --> m Library Dependencies. For me I had to add the appcompact v7. As a side note I may encounter this again because I'm developing using material theme which I'm not sure right now is part of appcompact :/ – natur3 Dec 27 '14 at 14:38
  • Thank You very much .. Worked for me.. :) – Deep Dave Dec 06 '16 at 02:53
7

You need to make sure you are using the latest support library as the DrawerLayout and other items were added in the May 2013 release.

  • Added DrawerLayout for creating a Navigation Drawer that can be
    pulled in from the edge of a window.

Aaron McIver
  • 24,527
  • 5
  • 59
  • 88
  • Updating it now to see if that's the issue. – Jhorra Jun 07 '13 at 21:46
  • I have all the API's updated an installed from 4.0 (API 14) up and all the extra tools. I restarted Android Studio and still get the same error. – Jhorra Jun 07 '13 at 22:04
  • If you look in the [SDK manager](http://developer.android.com/tools/help/sdk-manager.html) you should be able to see your current version and unless it is May 2013 that is your issue. I had to use some `explicit' force a few months back in IntelliJ to force the upgrade. – Aaron McIver Jun 07 '13 at 22:12
  • I removed it and readded it. You can see the pictures above. – Jhorra Jun 08 '13 at 01:45
2

You need to reference the support library in your project dependencies. Import the jar package into your java build path using the Project/Properties/Java Build Path/Libraries tab and use the button 'Add External JARs....'

Now compile the project.

skpal202
  • 1,217
  • 1
  • 9
  • 9