Android设计支持库在Eclipse中的错误

4

我尝试在Eclipse中导入"android.support.design"库,但导入后出现了一些错误:

/design/res/values/styles.xml:21: error: Error: No resource found that matches the given name: attr 'backgroundTint'.
/design/res/values/styles.xml:23: error: Error: No resource found that matches the given name: attr 'elevation'.
/design/res/values/styles.xml:34: error: Error: No resource found that matches the given name: attr 'elevation'. 
/design/res/values/styles.xml:56: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'.
/design/res/values/styles.xml:59: error: Error: No resource found that matches the given name: attr 'textAllCaps'.
/design/res/values/styles.xml:67: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.      
/design/res/values/styles.xml:71: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.     
/design/res/values/styles.xml:80: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'.     
/design/res/values/styles.xml:91: error: Error: No resource found that matches the given name: attr 'elevation'. 
/design/res/values/styles.xml:103: error: Error: No resource found that matches the given name: attr 'elevation'.  
/design/res/values/styles.xml:111: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Display1'. 
/design/res/values/styles.xml:21: error: Error: No resource found that matches the given name: attr 'backgroundTint'.
/design/res/values/styles.xml:23: error: Error: No resource found that matches the given name: attr 'elevation'.
/design/res/values/styles.xml:34: error: Error: No resource found that matches the given name: attr 'elevation'.  
/design/res/values/styles.xml:56: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'.
/design/res/values/styles.xml:59: error: Error: No resource found that matches the given name: attr 'textAllCaps'.
/design/res/values/styles.xml:67: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
/design/res/values/styles.xml:71: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Caption'.
/design/res/values/styles.xml:80: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Button'.
/design/res/values/styles.xml:91: error: Error: No resource found that matches the given name: attr 'elevation'.
/design/res/values/styles.xml:103: error: Error: No resource found that matches the given name: attr 'elevation'.
/design/res/values/styles.xml:111: error: Error retrieving parent for item: No resource found that matches the given name 'TextAppearance.AppCompat.Display1'.

我该如何修复? 谢谢。

你导入了资源文件吗?我建议你切换到Android Studio。 - Gabriele Mariotti
你好Gabriele, 我尝试使用Android Studio,但我更喜欢继续使用Eclipse。对于导入,我会按照以下步骤进行:文件 -> 导入 -> 从现有的Android代码导入到工作区 -> /android-sdk/extras/android/support/design那么google-play-services_lib或cardview_v7库应该怎么办呢? - alex193a
2个回答

5
根据 Android Design Support Library 的 Android 开发者博客,构建 Design Support 库需要依赖 Support v4 和 AppCompat Support Libraries。http://android-developers.blogspot.com/2015/05/android-design-support-library.html
因此,在 Eclipse 中,右键单击 android support design library 项目 -> 属性 -> Android,在底部的库部分,点击“添加”来将您的 AppCompat 库添加到该项目中。

相同的错误,但我使用了这个来解决:https://github.com/dandar3/android-support-design - alex193a

3

请在您的build.gradle文件中添加以下内容:

dependencies {

    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
}

在Eclipse中:(添加所有以上jar)
Your Project -> right click -> Properties -> Java Build Path -> Libraries -> Add Jar -> yourjar.jar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接