Question

OK, maybe it's just the lack of sleep, but I am having difficulty getting AppCompat classes to be visible in my Eclipse project, despite the fact that:

  • this project used to work
  • a Gradle build of this project works fine

Here's my Eclipse project setup:

ActionBarCompatDemo project setup in Eclipse

So, I have:

  • android-support-v4.jar in libs/
  • android-support-v7-appcompat attached as an Android library project

The symptom is that the AppCompat classes are not visible: Eclipse reports "The import android.support.v7.app cannot be resolved" when I try to import android.support.v7.app.ActionBarActivity. The android-support-v7-appcompat.jar file appears to have the class, and it appears to be properly added to my build path (by virtue of being in "Android Dependencies", which is checked in the Eclipse build path dialog).

Other notes:

  • I temporarily removed the appcompat library project from the Eclipse configuration, exported Gradle build files, and added it back, with no effect on Eclipse. Adding compile 'com.android.support:appcompat-v7:19.0.1' to the dependencies block in the Gradle build file was sufficient to get the project to build using gradle assembleDebug, so it's not like I have the import statement wrong.

  • I created a new project and have the same issue there, so it is not tied to this specific project.

  • The SDK Manager reports that I have 19.0.1 of the Android Support Library installed.

  • I have cleaned this project and appcompat, restarted Eclipse, and have tried various profanities, with no effect on Eclipse.

Any suggestions as to where I am going wrong?

UPDATE

Here's my Java build path, per Eclipse:

Eclipse Java build path

Was it helpful?

Solution

Well, I'm not completely certain what I did, but it's now working.

The most likely situation is that the directory had some of the wrong files marked read-only. Allowing all files to be writeable, plus restarting Eclipse for the fourth time today, eliminated my problems, in both projects (the one depicted above and another one).

Now, it's entirely possible that I did something else along the way that got picked up by the restart of Eclipse, or just that Eclipse wanted to restart (again) before it decided to behave.

Anyway, thanks to all who provided advice!

OTHER TIPS

Have you checked if the android-support-v4.jar is the same version in both projects? When you are using appcompat, in fact, you don't need the android-support-v4.jar, as it is packed in appcompat project. Another try is to verify if the Project Build Target of appcompat is <= project build target of your project.

Remove support jar from your project, since support jar is there in app-compat lib also.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top