androidx 和 com.android.support 的区别 [英] Difference between androidx and com.android.support

查看:39
本文介绍了androidx 和 com.android.support 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我注意到我可以使用两个不同的依赖项时,我正准备在我的项目中使用约束布局:

I was about to use a constraint-layout in my project when I noticed that there are two different dependencies that I can use:

  • com.android.support.constraint:constraint-layout
  • androidx.constraintlayout:constraintlayout

这两者之间是否有区别,或者有哪些更可取的建议?

Is there a difference between these two or some recommendation on which is preferable?

编辑

Google 将停止支持 com.android.support 并提示用户迁移到新的 androidx 等效版本.

Google is stopping support for com.android.support and prompts users to migrate to the new androidx equivalent.

注意:随着 Android 9.0(API 级别 28)的发布,有一个名为 AndroidX 的新版本支持库,它是 Jetpack 的一部分.AndroidX 库包含现有的支持库,还包含最新的 Jetpack 组件.

Note: With the release of Android 9.0 (API level 28) there is a new version of the support library called AndroidX which is part of Jetpack. The AndroidX library contains the existing support library and also includes the latest Jetpack components.

您可以继续使用支持库.历史工件(那些版本为 27 及更早版本并打包为 android.support.* 的工件)仍可在 Google Maven 上使用.但是,所有新的库开发都将在 AndroidX 库中进行.

You can continue to use the support library. Historical artifacts (those versioned 27 and earlier, and packaged as android.support.*) will remain available on Google Maven. However, all new library development will occur in the AndroidX library.

我们建议在所有新项目中使用 AndroidX 库.您还应该考虑将现有项目迁移到 AndroidX.

We recommend using the AndroidX libraries in all new projects. You should also consider migrating existing projects to AndroidX as well.

这是官方的迁移指南和相应的库等价物.

Here is the official Migration guide and the corresponding library equivalents.

推荐答案

所有支持库都删除了 v4 v7 v12 v13 等标签,所有内容都被重构到 androidx 包中.

All the support libraries are dropping the v4 v7 v12 v13 etc tags and everything is refactored into the androidx packages.

它们本质上是相同的,但为了将来参考,androidx 将是我们应该在我们的应用程序中使用的库.

They are essentially the same but for future reference androidx will be the library that we should use in our apps.

本周(2018 年 5 月 14 日那一周)发布的 Android studio 3.2 canary 应该具有允许自动重构 androidx 包的工具.在 google i/o 2018 上有一个关于这个的公告.

Android studio 3.2 canary that comes out this week (week of May 14, 2018) should have the tool that allows automatic refactoring to the androidx packages. There was an announcement about this at google i/o 2018.

这篇关于androidx 和 com.android.support 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆