android-无法找到与给定名称“android:TextAppearance.Material.Inverse”匹配的资源。

5

我已经下载了最新的Appcompat版本。这是我的Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 16
    buildToolsVersion '23.0.0'

    defaultConfig {
        applicationId "com.example.navid.recycleview"
        minSdkVersion 8
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:recyclerview-v7:23.0.0'
}

在SDK管理器中,我已经下载了API23和21的SDK平台和Google API。
当我重新构建项目时,它会打开v21\values-v21.xml文件,并且这个文件中有很多错误。
    F:\AndroidStudioProjects\recycleView\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v17\values-v17.xml
Error:(6, 21) No resource found that matches the given name: attr 'android:textAlignment'.
Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(13, 21) No resource found that matches the given name: attr 'android:paddingStart'.
Error:(17, 21) No resource found that matches the given name: attr 'android:layout_marginEnd'.
Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(23, 21) No resource found that matches the given name: attr 'android:layout_marginStart'.
Error:(26, 21) No resource found that matches the given name: attr 'android:layout_alignParentStart'.
Error:(6, 21) No resource found that matches the given name: attr 'android:textAlignment'.
Error:(10, 21) No resource found that matches the given name: attr 'android:paddingEnd'.
Error:(13, 21) No resource found that matches the given name: attr 'android:paddingStart'.
Error:(26, 21) No resource found that matches the given name: attr 'android:layout_alignParentStart'.
Error:(37, 21) No resource found that matches the given name: attr 'android:layout_toStartOf'.
Error:(40, 21) No resource found that matches the given name: attr 'android:layout_alignParentEnd'.
Error:(44, 21) No resource found that matches the given name: attr 'android:layout_toEndOf'.
Error:(37, 21) No resource found that matches the given name: attr 'android:layout_toStartOf'.
Error:(23, 21) No resource found that matches the given name: attr 'android:layout_marginStart'.
F:\AndroidStudioProjects\recycleView\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v21\values-v21.xml
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.EditText'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Subtitle'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Title'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.TextView.SpinnerItem'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(124, 21) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(128, 21) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(126, 21) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(127, 21) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(125, 21) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(122, 21) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(123, 21) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(131, 21) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(124, 21) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(128, 21) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(126, 21) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(127, 21) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(125, 21) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(122, 21) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(123, 21) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(131, 21) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless.Colored'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Small'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ButtonBar'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.CheckBox'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.RadioButton'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.DropDownItem.Spinner'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.PopupMenu'.
Error:(217, 21) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListPopupWindow'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView.DropDown'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.PopupMenu'.
Error:(217, 21) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.RatingBar'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner.Underlined'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.TextView.SpinnerItem'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Toolbar.Button.Navigation'.
Error:(124, 21) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(128, 21) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(126, 21) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(127, 21) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(125, 21) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(122, 21) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(123, 21) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
F:\AndroidStudioProjects\recycleView\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res\values-v23\values-v23.xml
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(1) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

什么问题?我该如何解决它?谢谢。

1
为了使用那个样式,你需要使用目标SDK版本23。让我猜猜,是Android Studio 1.3.1吗? - Daniel Nugent
2个回答

6

为了使用API 21提供的功能,您应该为参数compileSdkVersion指定相应的值:

android {
    compileSdkVersion 21
    buildToolsVersion '23.0.0'
    ...

属性 android:targetSdkVersion 只是告知系统您已经针对目标版本进行了测试,系统不应启用任何兼容性行为以维护您的应用与目标版本的向前兼容性。您可以在文档中获取更详细的描述。


0

尝试将appcompat更改为其他版本。

例如:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
}

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