What is Jetifier?

Ksenia picture Ksenia · Aug 4, 2018 · Viewed 54.6k times · Source

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"?

Answer

Khemraj picture Khemraj · Sep 26, 2018

Assuming that you are familiar with AndroidX. If not, please see @this post.

Jetifier will convert support libraries of all your dependencies to AndroidX automatically, if you don't set it to true then your project will have both, the support (got deprecated after 28.0.0 version) and AndroidX package, which is redundant.

For Example

If you have PhotoView.java in your dependency. That uses support library AppCompatImageView.

import android.support.v7.widget.AppCompatImageView;

This class is moved now to androidx package, so how will PhotoView get androidx AppCompatImageView? And app still runs in device.

Who made this run ?

Jetifier, which converts all support package of dependency at build time.

Jetifier will convert android.support.v7.widget.AppCompatImageView to androidx.appcompat.widget.AppCompatImageView while building the project.

Conclusion

Enabling Jetifier is important when you migrate from Support Libraries to AndroidX.

See this post to understand more about AndroidX.

Info

Your code may show compile time errors after enabling Jetifier while using dependency classes. which you can remove by deleting .idea, .gradle and re-sync project.

image2

image1