"Design" Eclipse 中的库即使使用 API 21 也无法编译

"Design" library in Eclipse doesn't compile even with API 21

因此,在 Design library 发布后,我赶紧开始设置它,这样我就可以开始将 material 设计添加到我现有的应用程序中。

但是,按照在 Eclipse 中设置库项目的常规说明(根据 http://developer.android.com/tools/support-library/setup.html),我发现设计库并不是开箱即用的。

这组错误围绕 xml 中缺少的属性标签。第一个和最后一个是:

design\res\values\styles.xml:21: error: Error: No resource found that matches the given name: attr 'backgroundTint'.
...
design\res\values\styles.xml:111: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Display1'.

现在,我知道你们中的许多人会赞同这句话 "You need to compile with API 21 not with API 7 (which is it's out of the box value)"。这也是我的第一个想法 - 但即使在使用 API 21 编译时(是的,清理后)它仍然 讨厌 这些标签。

(顺便说一句,我还注意到这些标签位于 /res/values/styles.xml 中,这肯定意味着这些样式将用于 API-7 设备 - 我假设在运行时,这些不是问题,要么被忽略,要么被编译出来。

有人遇到同样的问题 - 并且知道如何解决它吗?

非常简单的答案:

design 需要 v7/appcompat 库作为父库。

(您还需要将该库的 project.properties 更新为 API-21 才能编译)