Repository: facebook/react-native (language: cpp)

Issue:
[0.75][0.76] HAS FIX - React Native Android Build error - `zip END header not found` - INDIA Only
## IMPORTANT

> [!IMPORTANT]  
> The latest official update on this issue [is available here](https://github.com/facebook/react-native/issues/49115#issuecomment-2640333409)

### Description

When i run my react native app in debug mode which is already running without errors using npx react-native run-android command then suddenly it gives gradle build running error like below screenshot and description from today in all pc.

**My Configurations**
react-native: 0.76.1
gradle-wrapper version: gradle-8.10.2

```
BUILD FAILED in 935ms
error Failed to install the app. Command failed with exit code 1: ./gradlew app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build completed with 2 failures. 1: Task failed with an exception.
-----------
* Where:
Settings file '/Users/cspl01/...../android/settings.gradle' line: 2 * What went wrong:
Error resolving plugin [id: 'com.facebook.react']
> A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'. > java.util.zip.ZipException: zip END header not found * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
============================================================================== 2: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@7edd8fd3 of type BuildFlowService.Parameters > A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'. > java.util.zip.ZipException: zip END header not found * Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
============================================================================== BUILD FAILED in 935ms.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
```

please help me to solve this error!!



### Steps to reproduce

1. clone reproducer i have given or change configurations given by me in project
2. run yarn android(react-native run-android)
3. gradle plugin error occurs

### React Native Version

0.76.1

### Affected Platforms

Runtime - Android, Build - MacOS

### Output of `npx react-native info`

```text
System:
  OS: macOS 15.1
  CPU: (10) arm64 Apple M4
  Memory: 128.14 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 23.1.0
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.22
    path: ~/Kush/ReactNative/projects/SeaNeB-Mobile-App-All/SeaNeB-Mobile/node_modules/.bin/yarn
  npm:
    version: 10.9.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.11.11.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 24.1
      - iOS 18.1
      - macOS 15.1
      - tvOS 18.1
      - visionOS 2.1
      - watchOS 11.1
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.2 AI-242.23726.103.2422.12816248
  Xcode:
    version: 16.1/16B40
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.13
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: 15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.76.1
    wanted: 0.76.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true
```

### Stacktrace or Logs

```text
Executing tasks: [:gradle-plugin:react-native-gradle-plugin:clean, :gradle-plugin:shared-testutil:clean, :gradle-plugin:settings-plugin:clean, :gradle-plugin:clean, :gradle-plugin:shared:clean, :gradle-plugin:react-native-gradle-plugin:assemble, :gradle-plugin:react-native-gradle-plugin:testClasses, :gradle-plugin:shared-testutil:assemble, :gradle-plugin:shared-testutil:testClasses, :gradle-plugin:settings-plugin:assemble, :gradle-plugin:settings-plugin:testClasses, :gradle-plugin:assemble, :gradle-plugin:testClasses, :gradle-plugin:shared:assemble, :gradle-plugin:shared:testClasses] in project /Users/cspl01/....../android


FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Settings file '/Users/cspl01/..../android/settings.gradle' line: 2

* What went wrong:
Error resolving plugin [id: 'com.facebook.react.settings']
> A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'.
   > java.util.zip.ZipException: zip END header not found

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Failed to query the value of property 'buildFlowServiceProperty'.
> Could not isolate value org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@44ed0867 of type BuildFlowService.Parameters
   > A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'.
      > java.util.zip.ZipException: zip END header not found

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

BUILD FAILED in 126ms
```

### Reproducer

https://github.com/kush-scs/reproducer-gradle-build

### Screenshots and Videos

![Image](https://github.com/user-attachments/assets/ae35b7a6-a0ce-4ff1-816c-e047c9e6af72)


Discussion / hints:
> [!TIP]
> **Newer version available**: You are on a supported minor version, but it looks like there's a newer patch available - 0.76.6. Please [upgrade](https://reactnative.dev/docs/upgrading) to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
> [!TIP]
> **Newer version available**: You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please [upgrade](https://reactnative.dev/docs/upgrading) to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.
The solution to this error is UPGRADE react-native package to 0.77.0
**Given below Error **Automatically****
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'.
java.io.UncheckedIOException: java.util.zip.ZipException: zip END header not found
java.util.zip.ZipException: zip END header not found
org.gradle.internal.snapshot.impl.IsolationException: Could not isolate value org.jetbrains.kotlin.gradle.plugin.statistics.BuildFlowService$Parameters_Decorated@3ecb2b09 of type BuildFlowService.Parameters
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':gradle-plugin:react-native-gradle-plugin'.
java.io.UncheckedIOException: java.util.zip.ZipException: zip END header not found
java.util.zip.ZipException: zip END header not found
Same issue
Same issue
UPGRADE react-native package to 0.77.0 is working fine.
+1
+1

RN: 0.75.4
+1
> tive package to 0.77.0

this worked, also had to upgrade few libraries.
+1 Project was working fine till Friday and it suddenly stopped working on Monday.
Tried Cleaning the whole Project 
tried changing gradle version , Nothing Worked
I am facing same issue. It works well on friday and today when i run it throws error. I tried gradle delete from user, rebuild multiple times, deleted node modules multiple times, updated react-native version from 0.76.4 to 0.77.0 but still getting same error,

![Image](https://github.com/user-attachments/assets/57e083c9-cd2f-4a25-b290-7d805c3e0824)
+1

If you urgently need to fix this , just install @react-native/gradle-plugin to latest version and change the distribution URL accordingly . However this is highly not recommended .



@HemangiVekaria have you properly upgraded to 0.77 or just change version in package.json and install npm again?

>@HemangiVekaria have you properly upgraded to 0.77 or just change version in package.json and install npm again?

I run `npm uninstall react-native` and then run `npm install react-native.`
@gautamsamyak Yes bro i and all other developers world wide facing this issue on android side. All they and i also tried everting that we can think like  gradle delete from user, rebuild multiple times, deleted node modules multiple times, updated react-native version from 0.76.4 to 0.77.0 but still getting same error.
Version upgrade also downgrade and all other possibilities but the issue is not from our side it's a bug from it self the react native side we can't do anything they have to fix it any how because this same is is facing every one without changing any code of their project.
@HemangiVekaria very bed practice. You have to follow [https://react-native-community.github.io/upgrade-helper/?from=0.76.4&to=0.77.0](url) this.

You can also create a new project and transfer the src file to the new project.
@amithashtech I have already resolved this issue by creating a new project and transferring the old src to this.
@HemangiVekaria have you tried to create a new project and run on Android?
> [@HemangiVekaria](https://github.com/HemangiVekaria) have you tried to create a new project and run on Android?

Yes i created using` npx @react-native-community/cli@latest init` this and it gives me same error. Now i am trying to create new project again.
@HemangiVekaria first clean gradle using : **rm -rf ~/.gradle/** (Mac os) then try new project. 
but i am working on Same Project last 6 month so not prosible to update react native version, then how to possible to solve this error
===> https://www.linkedin.com/feed/update/urn:li:activity:7292144227868622848/
> [@HemangiVekaria](https://github.com/HemangiVekaria) first clean gradle using : **rm -rf ~/.gradle/** (Mac os) then try new project.

I am using window system. 
@SanjayKumarCode you have to wait until the react-native team does not give a patch. But as per my understanding upgrading project is not too hard. 
Just create a new project and move src, copy the old dependency from package json to new project package.json(except react-native and react).

if you have native code changes in Android and ios then you have to make these changes in the new project also.
@HemangiVekaria 
goto C:\Users\YourUsername\\.gradle and remove all inside this folder.


when you do nothing still something can be happend with you.😜😜. Yesturday everyghing was fine.  From morning i am also facing same issue. i updated/downloadgrade react native, gradle, reinstall npm and other stuff but nothing is working. 
> [@HemangiVekaria](https://github.com/HemangiVekaria) goto C:\Users<YourUsername>.gradle and remove all inside this folder.

I did that also 2 times. No success :(
Same i also do everything But still same issue 

Hey @gautamsamyak 
I tried to remove all inside this .gradle folder and created a new react native project but getting this error - 
 java.io.UncheckedIOException: Could not move temporary workspace (D:\project-name\android\.gradle\8.10.2\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-d89d4ba8-30f2-4589-b2a4-d298e51bcf31) to immutable location (D:\project-name\android\.gradle\8.10.2\dependencies-
accessors\569c8b261a8a714d7731d5f568e0e5c05babae10
Hello everyone,

I encountered a similar issue and managed to resolve it by using the [@react-native/gradle-plugin] 
https://www.npmjs.com/package/@react-native/gradle-plugin library.
Simply install the library and try rebuilding your project.

This is a temporary solution until React Native provides an official patch.

Thanks!
> Hello everyone,
> 
> I encountered a similar issue and managed to resolve it by using the [@react-native/gradle-plugin] https://www.npmjs.com/package/@react-native/gradle-plugin library. Simply install the library and try rebuilding your project.
> 
> This is a temporary solution until React Native provides an official patch.
> 
> Thanks!

Yes, Working well, you save my day 🙂, buddy 👍
> Hello everyone,
> 
> I encountered a similar issue and managed to resolve it by using the [@react-native/gradle-plugin] https://www.npmjs.com/package/@react-native/gradle-plugin library. Simply install the library and try rebuilding your project.
> 
> This is a temporary solution until React Native provides an official patch.
> 
> Thanks!

I added [@react-native/gradle-plugin] and now build get success. Thanks Jignesh-Rana. But i am getting another error related to syntax. Does anyone have any idea about this error? I am using 
```
"aws-amplify": "6.10.2",
    "aws-appsync": "4.1.10",
    "aws-appsync-auth-link": "3.0.7",
"@aws-amplify/analytics": "^7.0.58",
    "@aws-amplify/react-native": "^1.1.6",
    "@aws-amplify/rtn-push-notification": "^1.2.31",
    "@aws-amplify/rtn-web-browser": "^1.1.1",
```

![Image](https://github.com/user-attachments/assets/84834de5-b28b-4691-b78b-37df2b3c04dd)
> Hello everyone,
> 
> I encountered a similar issue and managed to resolve it by using the [@react-native/gradle-plugin] https://www.npmjs.com/package/@react-native/gradle-plugin library. Simply install the library and try rebuilding your project.
> 
> This is a temporary solution until React Native provides an official patch.
> 
> Thanks!


I had the same issue, and following this solution completely fixed it! After installing [@react-native/gradle-plugin](https://www.npmjs.com/package/@react-native/gradle-plugin) and rebuilding my project, everything worked perfectly.

A huge thank you for sharing this fix—you made my day! 🙌
> > Hello everyone,
> > I encountered a similar issue and managed to resolve it by using the [@react-native/gradle-plugin] https://www.npmjs.com/package/@react-native/gradle-plugin library. Simply install the library and try rebuilding your project.
> > This is a temporary solution until React Native provides an official patch.
> > Thanks!
> 
> I had the same issue, and following this solution completely fixed it! After installing [@react-native/gradle-plugin](https://www.npmjs.com/package/@react-native/gradle-plugin) and rebuilding my project, everything worked perfectly.
> 
> A huge thank you for sharing this fix—you made my day! 🙌

Can you Please share your Gradle Version In distribution Url?

> > > Hello everyone,
> > > I encountered a similar issue and managed to resolve it by using the [@react-native/gradle-plugin] https://www.npmjs.com/package/@react-native/gradle-plugin library. Simply install the library and try rebuilding your project.
> > > This is a temporary solution until React Native provides an official patch.
> > > Thanks!
> > 
> > 
> > I had the same issue, and following this solution completely fixed it! After installing [@react-native/gradle-plugin](https://www.npmjs.com/package/@react-native/gradle-plugin) and rebuilding my project, everything worked perfectly.
> > A huge thank you for sharing this fix—you made my day! 🙌
> 
> Can you Please share your Gradle Version?

"react": "18.3.1"
"react-native": "0.75.4"
"@react-native/gradle-plugin": "^0.77.0"
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip

Hello Everyone,
I have installed react-native-gradle-plugin in my existing project with react native 0.76.1
and distribution url - distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
but I am still getting this error -
 java.io.UncheckedIOException: Could not move temporary workspace (D:\project-name\android\.gradle\8.10.2\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-2771be0d-6ab8-4e40-879b-d36843a12914) to immutable location (D:\project-name\android\.gradle\8.10.2\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10)
 "react": "18.3.1",
https://github.com/riteshshukla04/React-native-zip-header-repro/commit/de19abbfa08e8f802f9f07d2db223315460423f2

The issue is not related to react native but of kotlin version 1.9.24. Try changing the kotlin version in RNGP(using patch package) and your build.gradle to 1.9.25 . See the referred commit above .
**when install in existing project @react-native/gradle-plugin then comes given below error** 

error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 FAILURE: Build failed with 
an exception. * Where: Settings file 'D:\sparepartwale-mobileapp\android\settings.gradle' line: 2 * What went wrong: Error resolving plugin [id: 'com.facebook.react.settings'] > Could not read workspace metadata from C:\Users\Brijesh\.gradle\caches\8.8\kotlin-dsl\accessors\b22002a57a45d84a557a6d199ea7ef01\metadata.bin * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. BUILD FAILED in 38s.
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
For me it's working 
library https://www.npmjs.com/package/@react-native/gradle-plugin
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
kotlinVersion = "1.9.24"
"react-native": "^0.75.4"

problem is related with gradle and kotlin only. so i dont think react native version will cause any issue.


> [riteshshukla04/React-native-zip-header-repro@de19abb](https://github.com/riteshshukla04/React-native-zip-header-repro/commit/de19abbfa08e8f802f9f07d2db223315460423f2)
> 
> The issue is not related to react native but of kotlin version 1.9.24. Try changing the kotlin version in RNGP(using patch package) and your build.gradle to 1.9.25 . See the referred commit above .

This worked, but still seems like a hack. What could be the root cause?
> [riteshshukla04/React-native-zip-header-repro@de19abb](https://github.com/riteshshukla04/React-native-zip-header-repro/commit/de19abbfa08e8f802f9f07d2db223315460423f2)
> 
> The issue is not related to react native but of kotlin version 1.9.24. Try changing the kotlin version in RNGP(using patch package) and your build.gradle to 1.9.25 . See the referred commit above .

This worked. Also had to bump versions in expo-core-modules
> Hello everyone,
> 
> I encountered a similar issue and managed to resolve it by using the [@react-native/gradle-plugin] https://www.npmjs.com/package/@react-native/gradle-plugin library. Simply install the library and try rebuilding your project.
> 
> This is a temporary solution until React Native provides an official patch.
> 
> Thanks!

You should avoid doing this as it will bump your RNGP(including AGP and gradle version) to latest version (0.77) while your project will still remain at RN-0.75.x (which is not meant for that version) .While this works, you may end up having issues on production 

Fix patch:
diff --git a/packages/helloworld/android/build.gradle b/packages/helloworld/android/build.gradle
index 928cdf5848165e..aba59eef2df9cd 100644
--- a/packages/helloworld/android/build.gradle
+++ b/packages/helloworld/android/build.gradle
@@ -12,7 +12,7 @@ buildscript {
         compileSdkVersion = 34
         targetSdkVersion = 34
         ndkVersion = "26.1.10909125"
-        kotlinVersion = "1.9.24"
+        kotlinVersion = "1.9.25"
     }
     repositories {
         google()
diff --git a/packages/react-native-gradle-plugin/gradle/libs.versions.toml b/packages/react-native-gradle-plugin/gradle/libs.versions.toml
index 026a9276e01912..e40ed90c1832bc 100644
--- a/packages/react-native-gradle-plugin/gradle/libs.versions.toml
+++ b/packages/react-native-gradle-plugin/gradle/libs.versions.toml
@@ -4,7 +4,7 @@ gson = "2.8.9"
 guava = "31.0.1-jre"
 javapoet = "1.13.0"
 junit = "4.13.2"
-kotlin = "1.9.24"
+kotlin = "1.9.25"
 assertj = "3.25.1"
 
 [libraries]
diff --git a/packages/react-native/gradle/libs.versions.toml b/packages/react-native/gradle/libs.versions.toml
index 2245fcee325fa3..d2416edf3d8276 100644
--- a/packages/react-native/gradle/libs.versions.toml
+++ b/packages/react-native/gradle/libs.versions.toml
@@ -23,7 +23,7 @@ javax-annotation-api = "1.3.2"
 javax-inject = "1"
 jsr305 = "3.0.2"
 junit = "4.13.2"
-kotlin = "1.9.24"
+kotlin = "1.9.25"
 mockito = "3.12.4"
 nexus-publish = "1.3.0"
 okhttp = "4.9.2"


Test patch: