How to define v7 appcompat dependency correctly?

前端 未结 3 542
一个人的身影
一个人的身影 2021-02-05 15:17

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 resolv

相关标签:
3条回答
  • 2021-02-05 15:38

    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.+"
    }
    
    0 讨论(0)
  • 2021-02-05 15:49

    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.

    0 讨论(0)
  • 2021-02-05 15:54

    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)

    0 讨论(0)
提交回复
热议问题