我正在开发一个使用RecyclerView组件的应用程序.我正在检查build.gradle文件,它具有以下依赖性:
I'm working on an app which uses the RecyclerView component. I was checking my build.gradle file and it had these dependencies:
compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:cardview-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5' compile 'com.android.support:design:25.3.1' testCompile 'junit:junit:4.12' compile 'com.android.support:support-v4:25.3.1'没有'com.android.support:recyclerview-v7:25.3.1',但是我在项目中有一个RecyclerView(android.support.v7.widget.RecyclerView).
There was no 'com.android.support:recyclerview-v7:25.3.1', and yet I had a RecyclerView (android.support.v7.widget.RecyclerView) in the project.
上面的哪些软件包还包含RecyclerView?还是我对支持库软件包不了解?
Which of the packages above also contains the RecyclerView? Or is there something I don't understand about the support library packages?
推荐答案
上面的哪些软件包还包含RecyclerView?
Which of the packages above also contains the RecyclerView?
没有一个. RecyclerView 位于 recyclerview-v7 中.
或者我对支持库软件包不了解吗?
Or is there something I don't understand about the support library packages?
design 对 recyclerview-v7 具有传递依赖.因此,取决于 design ,您的应用还取决于 recyclerview-v7 .这会自动为您处理.
design has a transitive dependency upon recyclerview-v7. Hence, by depending upon design, your app also depends upon recyclerview-v7. This is handled for you automatically.
您可以进一步简化依赖关系,因为 design 取决于 appcompat-v7 ,因此您无需自己请求 appcompat-v7 :
You could simplify your dependencies further, as design depends upon appcompat-v7, so you do not need to request appcompat-v7 yourself:
// compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:cardview-v7:25.3.1' compile 'com.android.support.constraint:constraint-layout:1.0.0-beta5' compile 'com.android.support:design:25.3.1' testCompile 'junit:junit:4.12' compile 'com.android.support:support-v4:25.3.1'然后,注释掉 support-v4 依赖项,看看是否存在构建问题.很有可能,您从那里使用的东西已经被其他东西引入了,因此您在 build.gradle 文件中也不需要该依赖项.
Then, comment out the support-v4 dependency and see if you have build problems. Most likely, what you are using from there is pulled in by something else already, and so you will not need that dependency in your build.gradle file either.
您可以在此处.
更多推荐
支持库中的RecyclerView在哪里?
发布评论