score:0

add the library to your application project:

  • in the project explorer, right-click your project and select properties.
  • in the category panel on the left side of the dialog, select android.
  • in the library pane, click the add button.
  • select the library project and click ok. for example, the appcompat project should be listed as android-support-v7-appcompat.
  • in the properties window, click ok.

if you open java build path dialog for the android-support-v7-appcompat project it should look like the one on the picture below.

java build path dialog in eclipse

score:0

i know this is a bit old but if anyone had the same issue i fixed like this: from gradle leave just the last v7 (mine is compile 'com.android.support:appcompat-v7:23.1.1' and i deleted compile 'com.android.support:appcompat-v7:22.2.0' ) after that go in your class and delete the import v7...after sync again and you will see that android studio will ask automatically you if you want import the new dialog. i hope this simple case will help someone.

score:1

after more research, i've concluded that this is a symptom of android issue 16472, in which things fail if you have a project on one drive and a library on another drive. the new mechanism, in which the adt plugin creates appcompat_v7 automatically when you set up a new project, exacerbates the problem. if the workspace is on the c: drive but you want the project files to be on some other drive, by unchecking "create project in workspace", the plugin will put the project files on your other drive but create appcompat_v7 on the c: drive, which automatically causes the problems reported for #16472.

it's probably best to set up the workspace on the same drive where you put the project files (but i haven't tested this; and in any case, having them on different drives hasn't caused a problem for me, for non-android java projects). however, i've found a way to work around this, by copying appcompat_v7 to the other drive:

  1. use the android application project wizard to create a new application, and let it create your project and a new appcompat_v7 project on different drives.
  2. using windows explorer or some other method, copy the newly created appcompat_v7 from c: to someplace on the other drive.
  3. in eclipse, delete the appcompat_v7 project.
  4. import -> android -> existing android code into workspace. browse to the location where you've made a copy of appcompat_v7, select it, and do the import. i found that it called the new project android-support-v7-appcompat, but this is ok. i waited for "building workspace" to complete (if you're set up not to build projects automatically, you may have to use build project on the new project).
  5. right-click on your application project, "properties", "android". the "library" section will probably have a path name (the path of appcompat_v7 on the c: drive) with a red x by it. click on add; a window with android-support-v7-appcompat should show up; click on that. it should be added to the library list with a green check mark. now select the path name on the c: drive, and click remove and then ok. i'd double-check by clicking on "properties" again, to make sure the library shows up and still has a green check mark.

after you do this, if your workspace is set up to build automatically, this should build your application successfully. (otherwise build it manually.)

if you later add another application to the same workspace, you don't need to repeat steps 2, 3, or 4. after the wizard creates your project and another new appcompat_v7 or appcompat_v7_2 or something, use step 5 to add the android-support-v7-appcompat you've already imported and remove the old library reference, then delete the duplicate appcompat_v7 that it just created. (see also remove v7 appcompat folder.)


Related Query

More Query from same tag