Fixed : React Native App Gradle Plugin Build error -(zip END header not found)

February 4, 2025 ·  · · React-Native Bug-Fix Android

Recently, a bug in React Native (RN) caused chaos. Thousands of developers went to sleep on Friday night with their applications running perfectly, only to return on Monday and find them completely broken.

This issue can show errors such as:

React Native App Gradle Plugin Build error - (zip END header not found)
[android] Plugin [id: 'com.facebook.react.settings'] was not found in any of the following sources

At first glance, these errors seem to be caused by corrupted Gradle files, but the exact reason for the corruption remains unclear.

Although an issue has been logged on the React Native GitHub repository, there has been no response from the RN team so far. However, I managed to fix the bug in my project by cleaning the build and installing a package called @react-native/gradle-plugin.

Most solutions suggested in the discussion involved upgrading the React Native version, but that would be a bad idea as it could introduce even more breaking changes in the code.

Steps to Fix the Bug

1. Delete Corrupt Gradle Caches

Run the following commands:

rm -rf ~/.gradle/caches
rm -rf ~/.gradle/wrapper
rm -rf android/.gradle

Then, stop any running Gradle processes:

./gradlew --stop

2. Delete and Reinstall Dependencies

Remove and reinstall project dependencies:

rm -rf node_modules
rm -rf android/build
rm -rf android/app/build
yarn install  # or npm install

3. Add @react-native/gradle-plugin

yarn add @react-native/gradle-plugin

4. Ensure Gradle and Kotlin Versions Are Updated

Check android/gradle/wrapper/gradle-wrapper.properties

Ensure the Gradle distribution URL is set correctly:

distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip

Check android/build.gradle

Make sure you are using a supported Kotlin version:

ext.kotlinVersion = "1.9.25"

5. Run the Build Again

Connect your Android device in USB debugging mode, then run:

cd android
./gradlew clean
./gradlew assembleDebug

Finally, start your app:

yarn react-native run-android

This should resolve the issue without the need to upgrade React Native. 🚀