什么是Jetifier? [英] What is Jetifier?

查看:433
本文介绍了什么是Jetifier?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是Jetifier?例如,要使用androidx打包的依赖项创建新项目,此新项目需要在 gradle.properties 文件中添加以下行:

android.enableJetifier=true

那是什么意思-启用喷射器"?

解决方案

今年的Google I/O(18),Google宣布了Jetpack,它可以设置/收集库以简化开发人员的生活.

Jetpack包括以前引入的Android体系结构组件(ViewModel,Room,Paging,LiveData等),以及新引入的体系结构组件(如WorkManager,Navigation).除此以外,Jetpack还具有其他库集,例如AndroidX,AndroidKTX等.

AndroidX是Android支持库(如支持,数据绑定,设计等)的新包结构.

例如现在,在开发人员中,在我们的项目中导入库时,开发人员将使用 androidx.databinding.而不是 android.databinding..

这使Google可以在其中的库包中添加 SemVer 语义版本控制.对于开发人员,这意味着我们不必为所有支持库使用相同的支持库版本.每一种支持或更好的说法是AndroidX库都将维护其自己的版本.

开发人员的另一个优势是,我们不必为项目中的所有支持库维护相同的版本.

关于Jetifier,它将在构建时转换所有依赖项支持包. 根据Jetifier的官方文档

Jetifier工具迁移依赖于支持库的库以依赖 等效的AndroidX软件包.该工具可让您迁移 直接使用单个库,而不是使用Android gradle 与Android Studio捆绑在一起的插件.

要在项目中使用AndroidX,我们必须将项目的targetSdkVersion设置为 28 ,并在 gradle.properties 文件中添加以下两行.

android.useAndroidX=true

android.enableJetifier=true

我希望这能回答您的查询.

编辑

此链接具有所有支持库组件与其AndroidX的映射对应部分.

还请参阅博客以获取详细说明关于AndroidX

What is Jetifier? For example, to create a new project using the androidx-packaged dependencies, this new project needs to add the following line to the gradle.properties file:

android.enableJetifier=true

So what does it mean - "enable jetifier"?

解决方案

This year's Google I/O (18), Google has announced Jetpack which is set/collection of libraries to make developer's life easier.

Jetpack includes previously introduced Android architecture components (ViewModel, Room, Paging, LiveData etc.) as well as newly introduced architecture components like WorkManager, Navigation. Apart from this Jetpack also has other set of libraries like AndroidX, AndroidKTX etc.

AndroidX is new package structure for Android support libraries like support, databinding, design etc.

e.g. now on wards developers will use androidx.databinding. instead of android.databinding. while importing libraries in our projects

This enables Google to add SemVer or Semantic Versioning in there library packages. For developers, this means we don't have to use same support library version for all support libraries. Every support or better to say AndroidX library will maintain its own versioning.

Another advantages for developers is that we don't have to care about maintaining same version for all support library in our project.

About Jetifier, it converts all support package of dependency at build time. As per official documentation of Jetifier

Jetifier tool migrates support-library-dependent libraries to rely on the equivalent AndroidX packages instead. The tool lets you migrate an individual library directly, instead of using the Android gradle plugin bundled with Android Studio.

To use AndroidX in a project we have to set targetSdkVersion for our project to 28 and add following 2 lines in gradle.properties file.

android.useAndroidX=true

android.enableJetifier=true

I hope this will answer your query.

EDIT

This link has mapping of all support library component with their AndroidX counter part.

Also please refer This blog for detailed explanation about AndroidX

这篇关于什么是Jetifier?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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