【问题标题】:What version of appcompat should I use in dependencies?我应该在依赖项中使用什么版本的 appcompat?
【发布时间】:2015-11-24 10:05:03
【问题描述】:

我正在使用最新版本的 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'.

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

【问题讨论】:

    标签: android android-studio android-support-library android-appcompat android-recyclerview


    【解决方案1】:

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

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

    会起作用的。

    【讨论】:

    • 感谢您的回复,但现在我收到此错误:F:\AndroidStudioProjects\recycleView\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.0\res \values-v21\values-v21.xml
    • @navidjons 请更新您的帖子并显示更详细的错误日志。
    • @navidjons 确保您已下载附加内容。 Prerequirements
    【解决方案2】:

    试试这个;

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

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

    【讨论】:

    • recyclerview-v7:23 是当前最新版本。
    【解决方案3】:

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

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

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

    如果您使用支持库 v23,您必须使用 API23 编译您的项目

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

      compileSdkVersion 23
    

    【讨论】:

      猜你喜欢
      • 2019-08-16
      • 2010-09-18
      • 2015-04-15
      • 1970-01-01
      • 2013-04-22
      • 2017-09-18
      • 1970-01-01
      • 1970-01-01
      • 2021-08-14
      相关资源
      最近更新 更多