The standalone Jetifier tool migrates support-library-dependent libraries to instead rely on the equivalent AndroidX packages. The tool lets you migrate an individual library directly instead of using the Android Gradle plugin bundled with Android Studio.
To install Jetifier, download the zip file and extract it. Your device must have Java version 1.8 or higher installed.
To process a library, pass the path to the current library and the path to the output file that the tool should create. Jetifier supports JAR, AAR, and ZIP files, including nested archives.
./jetifier-standalone -i <source-library> -o <output-library>
The following table lists the available options for the Jetifier tool commands:
||yes||Path to input library (JAR, AAR, or ZIP).|
||yes||Path to the output file. If the file already exists, Jetifier overwrites it.|
||no||Path to optional custom config file.|
||no||Logging level. Allowed values are:
||no||Operate in reverse mode ("de-jetification").|
||no||Rebuild the ZIP of Maven distribution according to the
generated POM file.
If set, all rewritten libraries are assumed to be part of Support Library. Not needed for jetification.
||no||Don't fallback when rules are missing; throw errors instead.|
||no||Don't throw an error when jetifying a signed library; strip the signature files instead.|
||no||Timestamps policy to use for the archived entries as their modified time. Values: keepPrevious (default) epoch or now.|
The following example runs the utility on the library
the current directory and writes the output to
result.aar in the same
./jetifier-standalone -i libraryToProcess.aar -o result.aar
Jetifier migrates Java, XML, POM, and ProGuard references that point to
android.support.* packages, changing them so they point to the corresponding
Since ProGuard wildcards for
android.support.* don't always map directly to
androidx.* packages, Jetifier produces all eligible substitutions.
If there is a type in an
android.support.* package that does not come from any
Support Library artifact, Jetifier still migrates the type as long as there is a
mapping for it. However, this migration is not guaranteed to work, as there
might not be mapping rules general enough to cover all the custom types.
The Jetifier utility supports some advanced use cases.
If you pass the
-r flag, the utility runs in reverse mode. In this mode, the
utility converts AndroidX APIs to the Support Library equivalents. Reverse mode
is useful if you are developing
libraries that use AndroidX APIs but also need to distribute versions that use
the Support Library.
The following example runs the utility in reverse mode on the library
myAndroidXLib.aar in the current directory and writes the output to
supportLibVersion.aar in the same directory:
./jetifier-standalone -r -i myAndroidXLib.aar -o supportLibVersion.aar
Custom config file
The Jetifier tool uses a config file to map Support Library classes to their AndroidX equivalents. If necessary, you can make a custom config file that alters this mapping. You can even add new classes to the mapping that are not actually members of the Support Library. For example, you might modify the mapping to replace one of your own classes with a successor class written to use AndroidX.
To use a custom config file:
- Extract the file
default.generated.configfrom the utility's
jetifier-core-*.jarfile and save it.
- Make any necessary edits to your copy of the config file.
- Pass your file to the utility with the
./jetifier-standalone -i libraryToProcess.aar -o result.aar -c myCustomMapping.config