Search code examples
androidantandroid-support-libraryandroid-build

How to define v7 appcompat dependency correctly?


I'm trying to get an (inherited) Android project to build. I'm using Ant & command line tools (and IDEA).

In styles.xml, there are references that cannot be resolved such as:

<style name="AppBaseTheme" parent="@style/Theme.AppCompat.Light">

This is the original error I ran into:

[...]/res/values/styles.xml:8: error: Error retrieving parent for item:
No resource found that matches the given name '@style/Theme.AppCompat.Light'.

I then noticed that project.properties has this appcompat reference which is broken on my (OS X) machine:

target=android-18
android.library.reference.1=../../../../adt-bundle-linux-x86_64/sdk/extras/android/support/v7/appcompat

I tried to fix that by making the reference relative to ${sdk.dir}:

android.library.reference.1=${sdk.dir}/extras/android/support/v7/appcompat

So now that path should be correct. But now when I run ant debug:

BUILD FAILED
/opt/android-sdk-macosx/tools/ant/build.xml:573: 
  /opt/android-sdk-macosx/extras/android/support/v7/appcompat resolve to a 
  path with no project.properties file for project /Users/joka/devel/project/

So, any ideas? What's the simplest way to get this project built?

(Please note that Ecplise-specific advice won't be useful to me.)

Edit: The Android SDK installation looks like this:

enter image description here


Solution

  • I ran into the same problem, so I tried using a relative path and that fixed the problem for me. It looks like only relative paths work with android.library.reference. I did a quick search to verify this, and came across this stackoverflow link which indicates that absolute paths will work with android.library.reference on Windows, but not on Unix or Mac.

    Peace.