react-native-legacy-patches
v1.0.0
Published
Patches and utilities to run legacy React Native projects on modern Android versions (API 34/35+)
Maintainers
Readme
react-native-legacy-patches
A zero-dependency CLI utility to apply essential compatibility patches and code modifications to legacy React Native projects (e.g. React Native 0.62.x and packages like reanimated v1, touch-id, widget-center) to compile and run on modern Android versions (Android 14+ / API 34 & 35).
The Problems This Solves
Gradle 7.x & 8.x Compatibility (
Plugin with id 'maven' not found): Older versions of native libraries (likereact-native-reanimatedv1 andreact-native-widget-center) use the deprecatedmavenplugin in theirbuild.gradle. Gradle 7+ completely removed it. This package patches them to usemaven-publishinstead.Android 14+ Broadcast Receiver Security Crashes (
SecurityException: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified): On Android 14 (API 34) and higher, registering a dynamic broadcast receiver without specifying export flags is a security violation and crashes the app immediately on startup. This tool patchesMainApplication.javato override and inject the safety flags globally, and also includes patches for the internal code of React Native.
Usage
You can run this tool directly without installation using npx:
1. List Available Patches
See which npm packages have compatibility patches available:
npx react-native-legacy-patches --list2. Apply a Specific Patch
Apply the patch for a single library (e.g. react-native-reanimated):
npx react-native-legacy-patches --patch react-native-reanimatedThis copies the .patch file into your local patches/ folder and applies it using patch-package.
3. Apply All Patches
Copy and apply all legacy compatibility patches at once:
npx react-native-legacy-patches --all4. Patch MainApplication.java (Android 14+ Compatibility)
Automatically scans your project's android/ directory and overrides registerReceiver in your MainApplication.java to prevent runtime SecurityException crashes:
npx react-native-legacy-patches --patch-appManual Integration / Local Setup
If you want to install it as a development dependency:
npm install --save-dev react-native-legacy-patchesThen add it to your package script or run locally:
npx react-native-legacy-patches --allContributing / Adding New Patches
To add a new patch to this repository:
- Make your changes to the target package inside
node_modules/. - Run
npx patch-package <package-name>to generate the patch in your project'spatches/folder. - Copy the generated
.patchfile into thepatches/folder of this repository. - The CLI will automatically detect the new patch and list it.
