我想在我的应用程序中包含 recyclerview,我已经更新了整个 sdk。 android 支持库是版本 17,android 支持库是版本 23。我在 sdk\extras\android\support\v7 目录中有 recyclerview 文件夹。
为了添加库,我将它们放在依赖项中:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:recyclerview-v7:21.0.0.+'
}
当我重建项目时,它显示了这个错误:
Error:(24, 13) Failed to resolve: com.android.support:recyclerview-v7:21.0.0.+ <a href="install.m2.repo">Install Repository and sync project</a><br><a href="openFile">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
我应该在依赖项中使用什么版本的 recyclerview?怎么知道呢?
编辑 我在 friend 的帮助下解决了最后一个问题,这是新的 gradle:
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'...............
如何解决这个问题?
最佳答案
你有这个问题是因为
compile 'com.android.support:recyclerview-v7:21.0.0.+'
是错误的。
你可以使用
compile 'com.android.support:recyclerview-v7:21.0.0'
compile 'com.android.support:recyclerview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.android.support:recyclerview-v7:+'
但是你不能用
compile 'com.android.support:recyclerview-v7:21.0.0.+'
当然,我建议您使用最新的支持库,目前是 23.1.0
compile 'com.android.support:recyclerview-v7:23.1.0'
注意。这需要使用 API 23 进行编译。
此外,我建议您避免使用 +。这不是一个好的选择,因为这样您将来无法复制您的构建。
关于android - 我应该在依赖项中使用什么版本的 recyclerview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32282711/