78

I am new to Android. Currently, I have the adt-bundle-windows-x86-20131030.zip (Windows 32 bit) installed - and have successfully installed the Android SDK and Eclipse. Also, I have updated everything in the Android SDK manager. Now, I am working in Android v-4.4.2

My project runs successfully, but when I import android.support.v7.app.ActionBarActivity; and import android.support.v7.app.ActionBar; the project won't debug. I get the error The Import android.support.v7 cannot be resolved

I searched in Google and installed Android Support Library then added v7 in my project.

  1. File->Import (android-sdk\extras\android\support\v7). Choose "appcompat"
  2. Project-> properties->Android. In the section library "Add" and choose "appCompat"

Screenshot

enter image description here

Successfully added in appCompat but still I am still getting the error.

PitaJ
  • 12,969
  • 6
  • 36
  • 55
Developer
  • 2,676
  • 8
  • 43
  • 65
  • see this link it is can help http://stackoverflow.com/questions/21876435/the-import-android-support-v7-app-mediarouteactionprovider-cannot-be-resolved – Meysam Jul 28 '14 at 15:43
  • You can try this https://stackoverflow.com/a/27114527/3729471
    Hope it's helps your problem
    – Zuldha May 06 '18 at 08:48

7 Answers7

170
  1. Go to your project in the navigator, right click on properties.

  2. Go to the Java Build Path tab on the left.

  3. Go to the libraries tab on top.

  4. Click add external jars.

  5. Go to your ADT Bundle folder, go to sdk/extras/android/support/v7/appcompat/libs.

  6. Select the file android-support-v7-appcompat.jar

  7. Go to order and export and check the box next to your new jar.

  8. Click ok.

ChristianCuevas
  • 2,672
  • 3
  • 19
  • 24
  • 2
    The above solution helped me import the support v7 files but now i m getting error at R. as R cannot be resolved to a variable. – Joyson Jun 09 '15 at 06:33
  • 1
    WOW - thank you. So many explanations import this export that, click button change file -- you nailed. – terary May 07 '16 at 17:05
  • @Joyson try to clean your project. I cleaned my project and it's resolve this error. – Muhammad Saqib Aug 21 '16 at 15:54
  • 1
    How do you get sdk/extras/android/support/v7/appcompat/libs? I've got C:\Program Files (x86)\Android\android-sdk\extras\android\m2repository\com\android\support, but no v7 in that folder. There's support/appcompat-v7, but it's just full of empty folders with version numbers as the folder names. – RoboticRenaissance Aug 07 '17 at 21:44
  • haha, i think we got the same situation here @RoboticRenaissance... because we're eclipse user nor android studio user. – gumuruh Jun 09 '18 at 18:02
  • Nah, I was using Android Studio. @gumuruh – RoboticRenaissance Jun 09 '18 at 19:27
26

I tried the answer described here but it doesn´t worked for me. I have the last Android SDK tools ver. 23.0.2 and Android SDK Platform-tools ver. 20

The support library android-support-v4.jar is causing this conflict, just delete the library under /libs folder of your project, don´t be scared, the library is already contained in the library appcompat_v7, clean and build your project, and your project will work like a charm!

enter image description here

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 2
    It's a really perfect solution, but it difficult situation for beginners – Dimon Mar 28 '16 at 22:40
  • 2
    Worked for me now I have another unresolve import error as -The import android.support.design cannot be resolved – sandy Aug 05 '16 at 05:45
4

In my case, the auto-generated project appcompat_v7 was closed. So just open up that project in Package Explorer.

Hope this help.

rosmianto
  • 76
  • 5
  • Btw, why does this work, Why do we need to open it? Another weird Eclipse bug? – Pacerier Nov 12 '14 at 09:27
  • must be opened if your project has the reference to this library, Properties -> Android -> See if the library is already specified. – Jorgesys Dec 01 '14 at 21:03
0

I had the same issue every time I tried to create a new project, but based on the console output, it was because of two versions of android-support-v4 that were different:

[2014-10-29 16:31:57 - HeadphoneSplitter] Found 2 versions of android-support-v4.jar in the dependency list,
[2014-10-29 16:31:57 - HeadphoneSplitter] but not all the versions are identical (check is based on SHA-1 only at this time).
[2014-10-29 16:31:57 - HeadphoneSplitter] All versions of the libraries must be the same at this time.
[2014-10-29 16:31:57 - HeadphoneSplitter] Versions found are:
[2014-10-29 16:31:57 - HeadphoneSplitter] Path: C:\Users\jbaurer\workspace\appcompat_v7\libs\android-support-v4.jar
[2014-10-29 16:31:57 - HeadphoneSplitter]   Length: 627582
[2014-10-29 16:31:57 - HeadphoneSplitter]   SHA-1: cb6883d96005bc85b3e868f204507ea5b4fa9bbf
[2014-10-29 16:31:57 - HeadphoneSplitter] Path: C:\Users\jbaurer\workspace\HeadphoneSplitter\libs\android-support-v4.jar
[2014-10-29 16:31:57 - HeadphoneSplitter]   Length: 758727
[2014-10-29 16:31:57 - HeadphoneSplitter]   SHA-1: efec67655f6db90757faa37201efcee2a9ec3507
[2014-10-29 16:31:57 - HeadphoneSplitter] Jar mismatch! Fix your dependencies

I don't know a lot about Eclipse. but I simply deleted the copy of the jar file from my project's libs folder so that it would use the appcompat_v7 jar file instead. This fixed my issue.

JohannB
  • 357
  • 6
  • 21
  • Hey see my answer will be useful for you. Your project must contain only one library android-support-v4.jar. – Jorgesys Nov 14 '14 at 18:00
0

I fixed it adding these lines in the build.grandle (App Module)

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar']) //it was there
   compile "com.android.support:support-v4:21.0.+" //Added
   compile "com.android.support:appcompat-v7:21.0.+" //Added
}
0

Recent sdk-manager's download does not contain android-support-v7-appcompat.jar But the following dir contains aar file C:\Users\madan\android-sdks\extras\android\m2repository\com\ android\support\appcompat-v7\24.2.1\appcompat-v7-24.2.1.aar This file can be imported by right-click project, import, select general, select archieve and finally select aar file. Even this does not solve the problem. Later remove 'import android.R' and add 'import android.support.v7.appcompat.*;' Follow this tutorial for other details: http://www.srccodes.com/p/article/22/android-hello-world-example-using-eclipse-ide-and-android-development-tools-adt-plugin

Tvs
  • 11
0

completing the answer @Jorgesys, in my case it was exactly the same way but the export configuration was missing in the library:

  1. right click on appcompat-v7 project;
  2. properties;
  3. left tab, Java Build Path;
  4. Right tab, Order and export;
  5. Check classes.jar with appcompat-v7;

export lib

rcorbellini
  • 1,307
  • 1
  • 21
  • 42