繁体   English   中英

我应该在依赖项中使用哪个版本的appcompat?

[英]What version of appcompat should I use in dependencies?

我正在使用最新版本的appcompat。 这是我的依赖项:

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

重建项目时,出现以下错误:

 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'...........it goes for about 50 more lines 
    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'.

问题是什么? 我该如何解决?

编辑:新的依赖项( recyclerview-v7:23.0.0' )和错误以及它:

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:(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'.

这些错误是在我使用新的依赖项时出现的

您应该始终使用相同级别的支持库。

例如,最好使用最新版本。 目前

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

如果使用的是支持库v23 ,则必须使用API​​23编译项目

在您的compileSdkVersion ,将build.gradle更改为23

  compileSdkVersion 23

您应该为RecyclerView使用与appcompat相同的版本。 所以,

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

会工作。

尝试这个;

compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'

我不确定是否有v7:23+可用于recyclerview

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM