【问题标题】:Why do CardView and RecyclerView require minSdkVersion L?为什么 CardView 和 RecyclerView 需要 minSdkVersion L?
【发布时间】:2014-09-01 03:35:31
【问题描述】:

在使用新的 Android 小部件 CardViewRecyclerView 时,我注意到它们需要 minSdkVersion L。因此,如果您的项目使用例如minSdkVersion 14,您将收到如下错误:

> Manifest merger failed : uses-sdk:minSdkVersion 14 cannot be smaller than version L declared in library com.android.support:cardview-v7:21.0.0-rc1 

我知道有一种解决方法是告诉 Gradle 忽略库的 minSdkVersion 并改用项目中的那个。

<uses-sdk tools:node="replace" />

但是,如果该库需要 Android L,那么忽略此错误并将其用于旧版本是否安全?为什么 Google 决定不让它们与 pre-L 版本一起工作?我猜是因为它不是最终版本?

【问题讨论】:

    标签: android gradle android-5.0-lollipop android-recyclerview android-cardview


    【解决方案1】:

    Google 在 I/O 上发布的所有 API(包括 CardViewRecyclerView)目前仅用作预览版,不应用于生产应用程序。

    这是 Google 防止这些库在完成和发布之前出现在生产应用程序中的方法。

    【讨论】:

      【解决方案2】:

      如果您现在确实想在早期版本的 Android 中使用其中任何一个,那真的很容易。只需在 build.gradle 文件中添加 RecyclerViewLib 作为依赖项。

      compile 'com.twotoasters.RecyclerViewLib:library:1.0.+@aar'
      

      作者在他的blog post 中谈到了它。所有依赖于 L 的代码都已被删除,因此可以安全使用。祝你好运!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-03-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-06-17
        • 1970-01-01
        • 2022-07-15
        相关资源
        最近更新 更多