Question

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

Was it helpful?

Solution 2

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.

OTHER TIPS

As Jay indicated, only relative paths will work on Unix/Mac.

For the Ant build to work, I also needed to generate build.xml for the appcompat project, using the command android update project -p <dir>, in my case:

/opt/android-sdk-macosx/tools/android update project 
    -p /opt/android-sdk-macosx-r22.0.1/extras/android/support/v7/appcompat

The exact config for me was:

android.library.reference.1=../../../../../../../opt/android-sdk-macosx/extras/‌​android/support/v7/appcompat

(This also works in local.properties, which I think is a better place since the same path won't work for all developers.)


I merely promoted my comment from 6 months ago into an answer as someone suggested.

By the way, now that I actually know something about Android development, I'd urge anyone who has the chance to ditch Ant and look into the new Gradle-based build system which is totally sweet in comprarison. It is CI-friendly and makes it easy to automate useful things (like using different package name and app icon for different build types). Stack Overflow will help when you run into problems.

Using the support libraries with Gradle, you'd skip all the above hassle and simply do:

dependencies {
    compile "com.android.support:appcompat-v7:18.0.+"
}

Your path seems to be wrong (you are missing the 'compatibility' part). The v7-appcompat library is at

{sdkpath}/extras/android/compatibility/v7/appcompat

for me (SDK Tools version 22.0.5 on Max OS X 10.7.5)

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