Search code examples
androideclipseworkspaceandroid-appcompat

Create Android project from source in Eclipse: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'


Developing Android apps in Eclipse.

I created an app in another app's workspace by mistake. I want to move it to its own workspace. For reasons I can't explain, the original workspace is now corrupt, but before I started I tar'ed up my app (project directory and all sub dirs) in a working state. This tar is what I have to work with.

So I...

  • Create a new workspace
  • Untar my backup tar file into (say) ~/scratch
  • File -> Import -> Android -> Existing Android Code Into Workspace.
  • Set "root directory" to ~/scratch/myApp
  • Tick "copy files into workspace"
  • Click Finish

The file hierarchy is now visible in the Package Explorer, but there are many (~100) red lines in the Console, which I think all boil down to much the same thing, so let's just look at the first Error in the Problems tab:

error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. styles.xml /myApp/res/values line 7 Android AAPT Problem

Some googling suggests that this is because I need "appcompat_v7" in my workspace, and for myApp to use it as a library. (Is this right?!) This is where I get stuck.

The short version is: "How do I add this?"

This is what I tried. (I've also tried variations on this theme, too many to list or even remember.)

  • File -> Import -> Android -> Existing Android Code Into Workspace.
  • Set "root directory" to /home/mark/Development/adt-bundle-linux-x86-20140702/sdk/extras/android/support/v7/appcompat
  • Untick "copy files into workspace"
  • Click Finish

(I would then go to Package Explorer -> myApp -> Properties -> Project References and check "android-support-v7-appcompat but I won't do that for now because...)

The Console has another 100 or so red lines, and we have another "Error":

error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'. styles_base.xml /android-support-v7-appcompat/res/values-v21 line 75 Android AAPT Problem

I must be doing something wrong here. My feeling is that the importing-my-app part is probably about right - I can at least understand why it can't find 'Theme.AppCompat.Light'. But the appcompat import seems to have gone completely wrong.

Any help gratefully received! I've been hacking around with this for several hours now and can't get any closer. (I have managed, however, to damage by original workspace so that that no longer works either. Brilliant.)

Thanks! -Mark


Solution

  • Fixed it.

    Solution was a combination of the steps here (most notably the "add to build path" bits) and getting the appcompat library from the earlier project, not from the SDK, which (for some reason I don't understand) is different.

    Working now anyway.