AndroidX transition tool for React Native that converts between Android Support Library and AndroidX dependencies
npx @tessl/cli install tessl/npm-jetifier@2.0.0Jetifier is the AndroidX transition tool in npm package format, designed specifically for React Native projects. It automatically converts Android Support Library dependencies to AndroidX equivalents and vice versa by performing source code transformations on node_modules dependencies.
⚠️ Deprecation Notice: Jetifier is deprecated. Future versions of React Native CLI may not run it by default.
npm install --save-dev jetifiernpm install -g jetifierFor programmatic access to utility functions:
const { getClassesMapping, readDir, chunk } = require('jetifier/src/utils');Note: Jetifier is primarily designed as a command-line tool rather than a programmatic API.
Convert Android Support Library dependencies to AndroidX (default mode):
# Install as dev dependency
npm install --save-dev jetifier
# Run jetifier to convert Support Library to AndroidX
npx jetify
# Or use the alias
npx jetifierConvert AndroidX dependencies back to Android Support Library:
# Run in reverse mode
npx jetify reverse
# Or use the short flag
npx jetify -rFor React Native 0.60+, jetifier runs automatically with the React Native CLI. For manual integration, add to package.json:
{
"scripts": {
"postinstall": "npx jetify"
}
}Jetifier uses a multi-worker architecture for efficient processing:
Primary interface for running jetifier transformations.
# Forward jetification (default)
npx jetify
# Reverse jetification
npx jetify reverse
npx jetify -r
# Standalone JAR/AAR/ZIP processing
npx jetifier-standalone [options] <input> <output>
npx jetifier-standalone -h # Show helpSupported File Types:
.java - Java source files.xml - Android XML files.kt - Kotlin source filesProcessing Modes:
forward (default): Convert Support Library → AndroidXreverse: Convert AndroidX → Support LibraryInternal utility functions available for programmatic access.
/**
* Load and process AndroidX class mapping data from CSV file
* @returns {Array<Array<string>>} Array of [oldClass, newClass] mapping pairs
*/
function getClassesMapping();
/**
* Recursively read directory to find Java, Kotlin, and XML files
* @param {string} dir - Directory path to scan recursively
* @param {Array<string>} filesList - Optional array to accumulate file paths (default: [])
* @returns {Array<string>} Array of file paths with .java, .xml, or .kt extensions
*/
function readDir(dir, filesList = []);
/**
* Split array into approximately equal chunks for worker distribution
* @param {Array} array - Array to split into chunks
* @param {number} chunkSize - Number of chunks to create (typically CPU count)
* @returns {Array<Array>} Array of arrays where each sub-array is a chunk
*/
function chunk(array, chunkSize);Core transformation engine that processes files using class mappings.
/**
* Worker process message interface
* @interface WorkerMessage
*/
interface WorkerMessage {
/** Chunk of files to process */
filesChunk: string[];
/** Class mapping pairs for transformation */
classesMapping: Array<[string, string]>;
/** Processing mode: 'forward' or 'reverse' */
mode: 'forward' | 'reverse';
}Processing Strategy:
Java-based jetifier for processing JAR/AAR/ZIP files directly.
# Process individual files
jetifier-standalone input.aar output.aar
# Common options
jetifier-standalone -h # Show help
jetifier-standalone -v # Verbose output
jetifier-standalone -r input.aar output.aar # Reverse modeSupported Archive Types:
.jar - Java Archive files.aar - Android Archive files.zip - ZIP archives containing Android codeJetifier uses the official AndroidX class mapping with custom additions:
Support Library class,Android X class
android.support.v4.app.Fragment,androidx.fragment.app.Fragment
android.support.v7.app.AppCompatActivity,androidx.appcompat.app.AppCompatActivityCustom Mappings:
android.support.v8.renderscript → android.renderscript# No specific environment variables required
# Jetifier automatically detects node_modules directory/**
* File filtering criteria
*/
const FILE_EXTENSIONS = ['.java', '.xml', '.kt'];
const SEARCH_DIRECTORY = 'node_modules';
const SKIP_SYMBOLIC_LINKS = true;Wildcard Import Issues:
// Problematic - will not convert properly
import android.support.v4.content.*;
// Solution - use concrete imports
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;Duplicate AndroidManifest.xml:
CompileSdk Version Conflicts:
# Verify node_modules structure
ls -la node_modules/
# Check for symbolic links (skipped by jetifier)
find node_modules/ -type l
# Manually verify transformations
grep -r "android.support" node_modules/ --include="*.java"
grep -r "androidx" node_modules/ --include="*.java"{
"name": "my-rn-app",
"devDependencies": {
"jetifier": "^2.0.0"
},
"scripts": {
"postinstall": "npx jetify",
"android": "npx jetify && npx react-native run-android"
}
}For library authors supporting both AndroidX and pre-AndroidX users:
android {
compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : 28
dependencies {
def support_version = project.hasProperty('supportLibVersion') ? project.supportLibVersion : '28.0.0'
def appcompat_lib = project.hasProperty('appCompatLib') ? project.appCompatLib : 'com.android.support:appcompat-v7'
implementation "${appcompat_lib}:${support_version}"
}
}# GitHub Actions example
- name: Install dependencies
run: npm install
- name: Run jetifier
run: npx jetify
- name: Build Android
run: npx react-native run-android --variant=release/**
* Processing mode constants
* @type {string} Either 'forward' or 'reverse'
*/
const ProcessingMode = 'forward' | 'reverse';
/**
* Class mapping array structure
* @type {Array<string>} Two-element array: [oldClassName, newClassName]
*/
const ClassMapping = [string, string];
/**
* Worker message object structure sent to child processes
* @typedef {Object} WorkerMessage
* @property {Array<string>} filesChunk - Array of file paths to process
* @property {Array<Array<string>>} classesMapping - Array of [oldClass, newClass] pairs
* @property {string} mode - Processing mode: 'forward' or 'reverse'
*/