Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
126 views
in Technique[技术] by (71.8m points)

android - What is Jetifier?

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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...