Open In App

Android – Jetifier

Last Updated : 25 Aug, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

By using the standalone Jetifier tool, libraries that rely on support libraries are converted to use comparable AndroidX packages. Utilizing the tool, you can migrate a single library without using the Android Gradle plugin included with Android Studio.

So What’s the Usage?

Pass the path to the current library and the path to the output file that the tool should create in order to process a library. Jetifier supports nested archives in JAR, AAR, and ZIP files. Jetpack is a collection of tools, guides, and libraries that make it easier for you to create high-quality apps. By following best practices, reducing boilerplate code, and streamlining challenging processes, Jetpack makes development simpler. All with the intention of allowing you to concentrate on the code that matters to you the most. The package name for all of the libraries included with Jetpack is AndroidX. Consider AndroidX to be the open-source initiative used to create, test, release, and modify the Jetpack libraries. Because the Android Gradle Plugin must convert all the support-library-dependent artifacts to AndroidX, having Jetifier enabled on your project (android.enableJetifier = true on your gradle.properties) affects the build performance. Therefore, if you want to slow down the build process for your Android project, deactivating jetifier is a smart option. But it’s not always an easy process to achieve that. To help you properly migrate your app to AndroidX and then securely stop Jetifier, we have developed a list of 6 actions to take.

What is Android X?

For Android support libraries such as support, data-binding, design, etc., there is a new package format called AndroidX. It is just so astonishing that you won’t even need to get your old libraries converted to newer ones, it takes care of that process too! For instance, developers will now import libraries in our applications using androidx.data binding rather than android.databinding. Google may now include SemVer, or Semantic Versioning, in their library package as a result. This frees developers from having to utilize the same support library version across all support libraries. Each support, or better yet, each library for AndroidX, will keep track of its own versioning. The fact that we don’t have to worry about keeping the same version for every supported library in our project is another benefit for developers. More info about Android X is here. To add it to your Android App, you should simply declare it, this way:

android.enableJetifier=true
android.useAndroidX=true

Some sophisticated uses:

Some sophisticated use cases are supported by the Jetifier tool:

  • In reverse: When the -r option is used, the utility operates in reverse mode. In this mode, the tool reverses the process, converting AndroidX APIs to their support library equivalents. Reverse mode is helpful, for instance, if you need to release versions of libraries that utilize the support library while also creating libraries that use the AndroidX APIs.
  • Personalized configuration file: To translate support library classes into their AndroidX equivalents, the Jetifier tool utilizes a configuration file. If required, you can modify this mapping in a custom configuration file. Even new classes that aren’t technically part of the support library can be added to the mapping; for instance, you might change the mapping to replace one of your own classes with a replacement class that was created using AndroidX.

Conclusion

Using the Android Jetifier is crucial, if you don’t set it to true, your project will contain both the support (which became deprecated after the 28.0.0 release) and AndroidX packages, which is unnecessary. 


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads