LinuxCommandLibrary

jetifier

Migrate support libraries to AndroidX

TLDR

Migrate project dependencies to the AndroidX format

$ jetifier
copy

Migrate project dependencies from the AndroidX format
$ jetifier reverse
copy

SYNOPSIS

jetifier [-r] [-i ] [-o ]

PARAMETERS

-r
    Reverse mode: Convert from androidx.* to android.support.*. This is less common but can be useful in specific situations.

-i
    Specifies the input `.jar` or `.aar` file to be processed.

-o
    Specifies the output file name for the processed `.jar` or `.aar` file. If not provided, the input file is overwritten.

DESCRIPTION

The `jetifier` command is a standalone tool provided by Google that helps migrate Android libraries that depend on the legacy `android.support.*` libraries to use the newer `androidx.*` Jetpack equivalents. This is essential for projects that want to use the latest Android APIs and dependencies, as newer libraries often require Jetpack. The `jetifier` tool rewrites the bytecode of `.jar` files and the contents of `.aar` files to replace references to the old support libraries with the corresponding Jetpack artifacts. This allows older projects or dependencies that haven't been updated by their maintainers to still be used with newer Android development tools and libraries. It helps to keep projects up-to-date by mitigating incompatibility issues arising from library dependencies. It's typically used as a pre-processing step before building an Android project. The primary goal of `jetifier` is to eliminate build errors related to support library dependencies.

CAVEATS

The tool may not perfectly handle all cases. Manual inspection and adjustments may be required after running jetifier, especially for complex projects or those relying on reflection or other advanced techniques that might be affected by the library changes. It doesn't modify source code; it only rewrites compiled artifacts.

USAGE EXAMPLES

Convert a JAR file: jetifier -i input.jar -o output.jar
Convert an AAR file: jetifier -i input.aar -o output.aar
Reverse conversion: jetifier -r -i input.jar -o output.jar

BEST PRACTICES

Before running `jetifier`, it's recommended to back up the original `.jar` or `.aar` files. After running, thoroughly test the affected components to ensure no unexpected behavior has been introduced. Consider using the tool as part of your automated build process.

HISTORY

The `jetifier` tool was developed by Google as part of the Android Jetpack initiative. The purpose was to facilitate the transition from the older `android.support.*` libraries to the newer `androidx.*` libraries, which offer better package names and improved support for modern Android development practices. It became essential as Google and other library maintainers migrated to `androidx`, leaving older projects incompatible without a migration tool.

Copied to clipboard