Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.75.x/0.76.x] Failing to build on Windows - Could not move temporary workspace - Error resolving plugin [id: 'com.facebook.react.settings'] - java.io.UncheckedIOException #46210

Open
adhikarisandil32 opened this issue Aug 20, 2024 · 81 comments

Comments

@adhikarisandil32
Copy link

adhikarisandil32 commented Aug 20, 2024

IMPORTANT: The latest official update on this issue is here #46210 (comment)

FAILURE: Build failed with an exception.

* Where:
Settings file 'F:\tutorial-practice\frontend-development\react-native\native-cli-todo-app-2\android\settings.gradle' line: 2

* What went wrong:
Error resolving plugin [id: 'com.facebook.react.settings']
> java.io.UncheckedIOException: Could not move temporary workspace (F:\tutorial-practice\frontend-development\react-native\native-cli-todo-app-2\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-29ae1a11-17a6-474d-825c-7114fe1603d2) to immutable location (F:\tutorial-practice\frontend-development\react-native\native-cli-todo-app-2\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10)

This is the full error. The command I've used to create the project is npx @react-native-community/cli init TodoApp2 --directory ./native-cli-todo-app-2. The projects is created successfully. After I run npm run start and hit a, for android, build fails showing the above error. Another project which uses 0.74.3 is working just fine. Creating new project automatically uses 0.75.2 version which is fine, but it shows the error while building because of which development server doesn't start.
Screenshot 2024-08-21 010605

@rghanks

This comment was marked as duplicate.

@adhikarisandil32
Copy link
Author

facing same issue

@rghanks

I've found a trick though. hit npm run android, let it do its job all the way. Now exit the terminal, clear the console and then again hit npm run start. Work for me.

@parmarraj999
Copy link

facing same issue

@rghanks

I've found a trick though. hit npm run android, let it do its job all the way. Now exit the terminal, clear the console and then again hit npm run start. Work for me.

this is working for me also

@lq9958
Copy link

lq9958 commented Aug 22, 2024

+1 ,I tried switching different gradle versions but it didn't work.

@MaiThanhNam141

This comment was marked as duplicate.

@tecnologiacd2
Copy link

Roll back versions: 0.75.2 to 0.75.1

@react-native/gradle-plugin
react-native
@react-native/babel-preset
@react-native/eslint-config
@react-native/metro-config
@react-native/typescript-config

*Don't run npm/yarn fix, it updates without permission and becomes incompatible

@ericmtzmtz
Copy link

facing same issue

@rghanks

I've found a trick though. hit npm run android, let it do its job all the way. Now exit the terminal, clear the console and then again hit npm run start. Work for me.

Don't work for me 😭

@KaziReazulislam1999

This comment was marked as off-topic.

@Agent009
Copy link

None of the proposed solutions seem to be working.

  • Changed Java version from 17 to 21
  • Downgraded from gradle 8.8 to 8.6/8.5
  • Downgraded from RN 0.75.2 to 0.75.1
  • Cleared cache, deleted .gradle and build directories.

It always gets stuck at the same spot with the same error.

@adhikarisandil32
Copy link
Author

adhikarisandil32 commented Aug 25, 2024

@Agent009 may be downgrade a version not on the same app but create a completely new project using npx @react-native-community/cli init ProjectName --version=0.74. just give it a try

@Agent009
Copy link

Downgrading to RN 0.74.5 and Gradle 8.5 solves the issue.
Wonder how the new release has been working for other folks. May just be an issue with those with simulated devices running on emulators?

@adhikarisandil32
Copy link
Author

Downgrading to RN 0.74.5 and Gradle 8.5 solves the issue. Wonder how the new release has been working for other folks. May just be an issue with those with simulated devices running on emulators?

@Agent009 I use it on real actual device and I face the same issue. I don't know. Nobody seems to be working on it. And I don't know react native enough to work on it. I don't know how to direct contributers to this issue.

@robhogan robhogan transferred this issue from facebook/metro Aug 26, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Aug 26, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@robhogan
Copy link
Contributor

robhogan commented Aug 26, 2024

Transferred to facebook/react-native as this isn’t Metro related and I can’t help directly. It looks like it might be specific to the community CLI but clearly it’s affecting quite a few people. CC @cortinico

@Ibeenoch

This comment was marked as off-topic.

@raahimkhan

This comment was marked as off-topic.

@raahimkhan

This comment was marked as off-topic.

@ralppppy
Copy link

This works for me #46046 (comment)

@GangulyYadavCDAT
Copy link

i was facing the same issue what i just did to solve is
cd android
then
gradlew clean or ./gradlew clean
then
gradlew build or ./gradlew build
whatever works for you give it a try
then run your project

@cortinico cortinico changed the title Error resolving plugin [id: 'com.facebook.react.settings'] Error resolving plugin [id: 'com.facebook.react.settings'] - java.io.UncheckedIOException: Could not move temporary workspace Aug 28, 2024
@cortinico cortinico added the Platform: Windows Building on Windows. label Aug 28, 2024
@cortinico cortinico changed the title Error resolving plugin [id: 'com.facebook.react.settings'] - java.io.UncheckedIOException: Could not move temporary workspace [0.75.x] Failing to build on Windows - Error resolving plugin [id: 'com.facebook.react.settings'] - java.io.UncheckedIOException: Could not move temporary workspace Aug 28, 2024
@cortinico
Copy link
Contributor

cortinico commented Aug 28, 2024

Due to a various of random comments, it's extremely hard for us to understand what happened here.

Please refrain from commenting "same issue" as that creates only unnecessary noise

As far as I understood:

  1. The issue is happening only on Windows
  2. The issue is happening only on React Native 0.75.x

If that is NOT the case for you -> Open another issue and do not comment here.

I've sharing some steps that could (hopefully help till we try to identify what's the issue):

  1. Make sure you don't have a version of @react-native/gradle-plugin specified in your package.json. If you have it, please remove it.
  2. Check with yarn why @react-native/gradle-plugin that the output is:
$ yarn why @react-native/gradle-plugin
├─ react-native@npm:0.75.1
│  └─ @react-native/gradle-plugin@npm:0.75.1 (via npm:0.75.1)
│
└─ react-native@npm:0.75.1 [473c9]
   └─ @react-native/gradle-plugin@npm:0.75.1 (via npm:0.75.1)
  1. Kill all the Gradle daemons with cd android && ./gradlew --stop
  2. Remove the .gradle folder with cd android && rm -rf .gradle/ && rm -rf ~/.gradle/caches
  3. Attemp to downgrade to Gradle 8.6 by changing this file android/gradle/wrapper/gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
  1. Attempt to upgrade to Gradle 8.10 by editing the same file.

Please report back if this solves the issue @Agent009

@cortinico
Copy link
Contributor

(Related to gradle/gradle#27844)

@lalithasj
Copy link

Hi @Sathvik-Rao
Thank you for your suggestion, android emulator and metro are running properly. I did steps 3 and 4, but unfortunately, there is no progress.

@lalithasj
Copy link

Hi,
Thanks, everyone for your valuable suggestions. Upgrading Gradle, Android Studio, and Emulator helps to resolve problems.

@Agent009
Copy link

Hey all, I've just tried to create a new project on 0.75.3 on Windows and I was able to successfully build with my machine. I also noticed several users in this thread managed to unblock themselves.

This issue seems to be related to Gradle > 8.6 versions and a new execution model which is not Windows-friendly (specifically if you have an Antivirus).

We'll keep you updated if we have an official workaround other than the one we already shared here: #46210 (comment)

I've tried all the permutations of the "fixes" posted so far, clearing all the necessary folders before doing so on each iteration, and none of them have resolved the issue for me.

It should be noted that I'm having issues with an existing project. A lot of the "fixes" seem to be for newly initiated projects.
However, clearing the cache, build and gradle folders should put existing projects in the same state as new projects so I'm not quite sure why it's working for some and not for others.

@cortinico
Copy link
Contributor

Small update: I've been discussing with engineers on Gradle to attempt to mitigate this issue happening on Windows machines:

I will share more updates or workarounds as soon as we have them.

@naizelei
Copy link

IMPORTANT: The latest official update on this issue is here #46210 (comment)

FAILURE: Build failed with an exception.

* Where:
Settings file 'F:\tutorial-practice\frontend-development\react-native\native-cli-todo-app-2\android\settings.gradle' line: 2

* What went wrong:
Error resolving plugin [id: 'com.facebook.react.settings']
> java.io.UncheckedIOException: Could not move temporary workspace (F:\tutorial-practice\frontend-development\react-native\native-cli-todo-app-2\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-29ae1a11-17a6-474d-825c-7114fe1603d2) to immutable location (F:\tutorial-practice\frontend-development\react-native\native-cli-todo-app-2\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10)

This is the full error. The command I've used to create the project is npx @react-native-community/cli init TodoApp2 --directory ./native-cli-todo-app-2. The projects is created successfully. After I run npm run start and hit a, for android, build fails showing the above error. Another project which uses 0.74.3 is working just fine. Creating new project automatically uses 0.75.2 version which is fine, but it shows the error while building because of which development server doesn't start. Screenshot 2024-08-21 010605

I had the same issue. What I did is just just delete the ".gradle" folder under the android folder. Then, run "npm run android" and it started building.

@BarbaraRamalho
Copy link

BarbaraRamalho commented Sep 29, 2024

Do you have react-native installed? The new "Get Started Without a Framework" from React-Native's website asks you to uninstall previous react-native versions, but then never gives you the command to install anything back.

If you are just following the commands written you might fail to do so.

https://reactnative.dev/docs/getting-started-without-a-framework

@twinedo
Copy link

twinedo commented Sep 30, 2024

For React Native 0.75.3, Please try :

  • java version : 21
  • android gradle plugin: 8.5.0
  • gradle-wrapper.properties: gradle-8.7-bin.zip / gradle: 8.7.0
  • gradle clean

make sure you're connected to internet

@Gagan1525
Copy link

@Agent009 may be downgrade a version not on the same app but create a completely new project using npx @react-native-community/cli init ProjectName --version=0.74. just give it a try

Thanks, it worked for me

@alexsvt2
Copy link

alexsvt2 commented Oct 6, 2024

@Agent009 may be downgrade a version not on the same app but create a completely new project using npx @react-native-community/cli init ProjectName --version=0.74. just give it a try

Thanks, it worked for me

This also worked for me, but with a small fix: downgrading Gradle from 8.6 to 8.5.

android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip

@EzioLi01
Copy link

EzioLi01 commented Oct 10, 2024

Using npx react-native run-android in admin terminal instead of npm run android is working for me.

@sncbtz
Copy link

sncbtz commented Oct 12, 2024

facing same issue

@rghanks

I've found a trick though. hit npm run android, let it do its job all the way. Now exit the terminal, clear the console and then again hit npm run start. Work for me.

Yeah it did the trick for me also 👍

@lf7817
Copy link

lf7817 commented Oct 15, 2024

close windows defender

@nyagami
Copy link

nyagami commented Oct 16, 2024

Hi guys, as @cortinico stated, Windows Defender might be causing the issue.
Follow these steps to ignore your project folder from Windows Defender.

To @cortinico, I think RN should ask user to ignore project build from Windows Defenders when we run npm run android (like Android Studio asks when we start new android project)

Good luck!

@cortinico
Copy link
Contributor

Hi guys, as @cortinico stated, Windows Defender might be causing the issue. Follow these steps to ignore your project folder from Windows Defender.

To @cortinico, I think RN should ask user to ignore project build from Windows Defenders when we run npm run android (like Android Studio asks when we start new android project)

As I shared in my previous comment, we're waiting for a fix from Gradle to this matter.
A patch for this problem will ship in Gradle 8.11 which is not out yet.

It's true that disabling Windows Defender and other antivirus are likely to reduce this issue, due to how file locking works on Windows. Anyway we won't be officially recommending it as it exposes your system to security issues.

@nirmanyu007
Copy link

Downgrading to RN 0.74.5 and Gradle 8.5 solves the issue. Wonder how the new release has been working for other folks. May just be an issue with those with simulated devices running on emulators?

thankyou so much brother because of you i was able to solve this error. I am so greatfull

@dubiao
Copy link

dubiao commented Oct 29, 2024

run

cd android && ./gradlew --stop

and then rebuild. That saved my lifetime

@cortinico cortinico changed the title [0.75.x] Failing to build on Windows - Could not move temporary workspace - Error resolving plugin [id: 'com.facebook.react.settings'] - java.io.UncheckedIOException [0.75.x/0.76.x] Failing to build on Windows - Could not move temporary workspace - Error resolving plugin [id: 'com.facebook.react.settings'] - java.io.UncheckedIOException Oct 29, 2024
@react-native-bot react-native-bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Oct 29, 2024
@react-native-bot

This comment was marked as off-topic.

@cortinico cortinico removed Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Oct 29, 2024
@samarjeetmohanty
Copy link

It worked for me
cd android
./gradlew clean

@ashikgowdaa
Copy link

I used npx @react-native-community/cli@latest init MyApp command to create native app , then i encountered an error while building
java.io.UncheckedIOException: Could not move temporary workspace, the issue got solved using

npx react-native run-android this command , before running this clean gradle build ./gradlew clean ,

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

@Ydenizd
Copy link

Ydenizd commented Nov 8, 2024

@Agent009 may be downgrade a version not on the same app but create a completely new project using npx @react-native-community/cli init ProjectName --version=0.74. just give it a try

Thanks, it worked for me

This also worked for me, but with a small fix: downgrading Gradle from 8.6 to 8.5.

android/gradle/wrapper/gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip

This one worked for me. Thanks

@bartlian
Copy link

bartlian commented Nov 9, 2024

it worked for me by yarn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests