使用support-v4和appcompat-v7

时间:2015-12-02 12:40:56

标签: android

这些是我在build.gradle

中的依赖项
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile files('libs/jdom-2.0.6.jar')

}

如果我重建项目,我会收到此错误。

Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ProgressBar.Horizontal'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.AutoCompleteTextView'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.EditText'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body1'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Body2'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Caption'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display1'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display2'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display3'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Display4'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Headline'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Large'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Medium'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Menu'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Subtitle'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.SearchResult.Title'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Small'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Subhead'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Title'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Menu'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Subtitle'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionMode.Title'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Large'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.PopupMenu.Small'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Button'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.TextView.SpinnerItem'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Subtitle'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.ActionBar.Title'.
Error:(121, 22) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(125, 22) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(123, 22) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(124, 22) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(122, 22) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(119, 22) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(120, 22) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(128, 22) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(121, 22) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(125, 22) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(123, 22) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(124, 22) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(122, 22) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(119, 22) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(120, 22) No resource found that matches the given name: attr 'android:colorPrimaryDark'.
Error:(128, 22) No resource found that matches the given name: attr 'android:windowElevation'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabText'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionBar.TabView'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.CloseMode'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ActionButton.Overflow'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Borderless.Colored'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Small'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ButtonBar'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.CheckBox'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.CompoundButton.RadioButton'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.DropDownItem.Spinner'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ImageButton'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabText'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.ActionBar.TabView'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Light.PopupMenu'.
Error:(215, 22) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListPopupWindow'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.ListView.DropDown'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.PopupMenu'.
Error:(215, 22) No resource found that matches the given name: attr 'android:overlapAnchor'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.RatingBar'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.SeekBar'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Spinner'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.TextView.SpinnerItem'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Toolbar.Button.Navigation'.
Error:(121, 22) No resource found that matches the given name: attr 'android:colorAccent'.
Error:(125, 22) No resource found that matches the given name: attr 'android:colorButtonNormal'.
Error:(123, 22) No resource found that matches the given name: attr 'android:colorControlActivated'.
Error:(124, 22) No resource found that matches the given name: attr 'android:colorControlHighlight'.
Error:(122, 22) No resource found that matches the given name: attr 'android:colorControlNormal'.
Error:(119, 22) No resource found that matches the given name: attr 'android:colorPrimary'.
Error:(120, 22) No resource found that matches the given name: attr 'android:colorPrimaryDark'.

究竟是什么问题?我想使用appcompat-v7因为我实现了导航抽屉。

我该怎么做才能解决问题。

修改

我编辑了我的gradle,如:

compileSdkVersion 21
buildToolsVersion "21.1.2"

但我还有其他一些错误:

\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.1.1\res\values-v23\values-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

这是我完整的gradle文件:

    android {
    compileSdkVersion 23
    buildToolsVersion "23.1.1"

    defaultConfig {
        applicationId "de.example.example.app"
        minSdkVersion 17
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
    repositories{
        mavenCentral()
    }

}

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

1 个答案:

答案 0 :(得分:1)

不要同时使用这两个库:v4和v7

只需切换到唯一一个更好的最新库,即:

compile 'com.android.support:appcompat-v7:23.1.1'

v7包含v4支持库,因此无需再次使用它

尝试添加此内容

 compile 'com.android.support:design:23.0.1'

您的build.gradle文件可能有问题,例如compleSdkVersion或buildToolsVersion。

因此,当您使用支持和设计v23时,您必须针对SDK 23进行编译。

compileSdkVersion 23
buildToolsVersion '23.1.1'

并尝试检查23.0.1而不是23.1.1如果您可能没有更新sdk,请尝试使用。

最后在发布build.gradle之后我发现你改变了 targetSdkVersion 23,也是清理,重建项目,尽可能尝试重启。 感谢