facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.16k stars 24.21k forks source link

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

Open adhikarisandil32 opened 3 weeks ago

adhikarisandil32 commented 3 weeks ago

IMPORTANT: The latest official update on this issue is here https://github.com/facebook/react-native/issues/46210#issuecomment-2346835978

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 commented 3 weeks ago

facing same issue

adhikarisandil32 commented 3 weeks ago

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 commented 3 weeks ago

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 commented 3 weeks ago

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

MaiThanhNam141 commented 3 weeks ago

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.

That's work for me! Thanks alot!!!!😍😍😍

tecnologiacd2 commented 3 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

@adhikarisandil32, thanks bro , i am facing same issue and it's work for me.

Agent009 commented 2 weeks ago

None of the proposed solutions seem to be working.

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

adhikarisandil32 commented 2 weeks ago

@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 commented 2 weeks ago

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 commented 2 weeks ago

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.

react-native-bot commented 2 weeks ago
:warning: Missing Reproducible Example
:information_source: 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 commented 2 weeks ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
robhogan commented 2 weeks ago

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 commented 2 weeks ago

still can't find a fix

raahimkhan commented 2 weeks ago

Facing same issue

raahimkhan commented 2 weeks ago

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.

I have the same versions but still getting the error.

ralppppy commented 2 weeks ago

This works for me https://github.com/facebook/react-native/issues/46046#issuecomment-2295388352

GangulyYadavCDAT commented 2 weeks ago

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 commented 2 weeks ago

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)
  3. Kill all the Gradle daemons with cd android && ./gradlew --stop
  4. Remove the .gradle folder with cd android && rm -rf .gradle/ && rm -rf ~/.gradle/caches
  5. 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 commented 2 weeks ago

(Related to https://github.com/gradle/gradle/issues/27844)

MDavidMR commented 2 weeks ago

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.7 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.7-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

  1. yarn why @react-native/gradle-plugin

Hi cortinico, I tried your suggestions step by step but the problem persists...

I'm so confused because yesterday I created a new proyect with 0.75.2 but it didn't run with 'npm run andoid' ( 'com.facebook.react.settings' error) so I changed it version to 0.75.1, after this, the project worked.

Today I tried to create other project following the previous 'hack' but 'com.facebook.react.settings' error is showing again.

cipolleschi commented 2 weeks ago

Hi @MDavidMR can you try to run gradlew clean and see if it resets the state of the machine? If you keep 0.75.2 and downgrade gradle to 8.7 as shown by @cortinico above, is the problem fixed?

harshmdr-devslane commented 2 weeks ago

Not working with RN 0.75.1 as well.

Cyberfolks commented 2 weeks ago

Hi @MDavidMR can you try to run gradlew clean and see if it resets the state of the machine? If you keep 0.75.2 and downgrade gradle to 8.7 as shown by @cortinico above, is the problem fixed?

yes it work for me i just downgraded gradle, deleted app/buld folder and then try to clean gradle. its done

cipolleschi commented 2 weeks ago

so it is due to https://github.com/facebook/react-native/issues/46210#issuecomment-2315211671 as Nicola pointed out. We can try to downgrade gradle and wait for 8.9 to come out with a fix. @blakef

projectninjatech commented 2 weeks ago

cd android ./gradlew clean ./gradlew --stop Then, go back to the root directory of your project and run: npx react-native run-android

I did this and it is working for me. You don't have to downgrade gradle with this method.

VcRajaa commented 2 weeks ago

cd android ./gradlew clean ./gradlew --stop Then, go back to the root directory of your project and run: npx react-native run-android

I did this and it is working for me. You don't have to downgrade gradle with this method.

I followed this, and working fine for me. Thanks dear

Renmsd commented 2 weeks ago

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?

how did you downgrade react native?

cipolleschi commented 2 weeks ago

@Renmsd don't do it, let's try first to run ./gradlew clean && ./gradlew --stop and see if it fixes

Renmsd commented 2 weeks ago

Screenshot 2024-08-30 181348

./gradlew clean && ./gradlew --stop

neglect that the error msg has changed (dont know why) but there is no such file with the name "./gradlew " @cipolleschi

MDavidMR commented 1 week ago

Hi @MDavidMR can you try to run gradlew clean and see if it resets the state of the machine? If you keep 0.75.2 and downgrade gradle to 8.7 as shown by @cortinico above, is the problem fixed?

Finally a working solution, no need to downgrade Gradle to 8.7. I'm just starting out with React-Native development and I was finding it very frustrating not being able to run a project immediately after creating it.

I also executed the command suggested by @projectninjatech : ./gradlew --stop

Thank you very much

cipolleschi commented 1 week ago

@Renmsd you have it right above the settings file....

You need to run ./gradlew from the android folder:

cd <path-to-your-project>\android
./gradlew clean
./gradlew --stop

perhaps on windows the command is slightly different (perhaps it is ./gradlew.bat?), but it's there

363226709-8cd22d47-5d34-474c-81fb-a9aa6f48786b

Agent009 commented 1 week ago

2. yarn why @react-native/gradle-plugin

Hi,

I tried both gradle 8.7 as well as 8.10 following your steps:

Gradle 8.7 gets stuck at the same point when running ./gradlew clean, stopping at this point in the gradle daemon output log:

2024-08-31T12:32:59.128+0100 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] Executing build with daemon context: DefaultDaemonContext[uid=11009b0a-f51f-48fd-abb3-36db1a89378b,javaHome=C:\Program Files\Java\jdk-21,daemonRegistryDir=C:\Users\user\.gradle\daemon,pid=28388,idleTimeout=10800000,priority=NORMAL,applyInstrumentationAgent=true,daemonOpts=-XX:MaxMetaspaceSize=512m,--add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=GB,-Duser.language=en,-Duser.variant]

Running npm run android ends with the same error as before:

Error resolving plugin [id: 'com.facebook.react.settings']
> java.io.UncheckedIOException: Could not move temporary workspace (C:\project\android\.gradle\8.7\dependencies-accessors\569c8b26
1a8a714d7731d5f568e0e5c05babae10-19d4b8ef-c0fc-408d-b528-17bd9053d50c) to immutable location (C:\project\android\.gradle\8.7\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10)

and gradle 8.10 errors with the following:

e: file:///project/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/build.gradle.kts:10:49: Unresolved reference: serviceOf
e: file:///project/node_modules/@react-native/gradle-plugin/react-native-gradle-plugin/build.gradle.kts:58:11: Unresolved reference: serviceOf

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file 'C:\project\node_modules\@react-native\gradle-plugin\react-native-gradle-plugin\build.gradle.kts' line: 10

* What went wrong:
Script compilation errors:

  Line 10: import org.gradle.configurationcache.extensions.serviceOf
                                                           ^ Unresolved reference: serviceOf

  Line 58:           serviceOf<ModuleRegistry>()
                     ^ Unresolved reference: serviceOf
Vantiboolean commented 1 week ago

When I downgraded the yarn version to 1.22, it worked

shubhkk07 commented 1 week ago
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

didn't work for Anyone can share other suggestions.

Renmsd commented 1 week ago

in Android folder I deleted .gradel and then ran these two lines rd /s /q .gradle and gradlew clean and it worked ( windows) I used Gardle 8.7

elmennani89 commented 1 week ago

I'm also facing this issue but in Mac with m1 chip. I used pnpm to install dependencies. When I checked node_modules/@react-native folder I couldn't find gradle-plugin inside it. so I installed it pnpm add @react-native/gradle-plugin and the issue went away.

note that for some reason also @react-native-community/cli needs to be installed

singhJasvinder101 commented 1 week ago

I was also getting the same error got the fix after installing node_modules / setup of react native project close your terminal and in new terminal then run

npm run android --clear-cache

kazisalman commented 1 week ago

Delete the ./gradle folder in C drive , then hit the commands again, it usually happens due to difference in gradle versions ( java versions)

UIT19521334 commented 1 week ago

still happen to me. Please help I was try

cd android && ./gradlew clean && ./gradlew --stop

but it still show error Where: Settings file 'D:\DAT\PoultryApps\android\settings.gradle' line: 2 * What went wrong: Error resolving plugin [id: 'com.facebook.react.settings'] > java.io.UncheckedIOException: Could not move temporary workspace

Edit: Some time it success some time it error so terrible image

MalekZishan commented 1 week ago

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.7 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.7-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

tnx bro save my day

MuruganBalachandran commented 5 days ago

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.

Well, It is Working for me also. i have been finding solution , for this problem . Thank you @rghanks

Coaquera commented 4 days ago

I have tried several things, I managed to work with β€œreact-native: β€œ0.75.2” and /gradle-8.8-all.zip

The order is important: 1.- Create the project -> npx @react-native-community/cli@latest init AwesomeProject 2.- If we have the virtual android we must close it. 3.- click on start virtual android(I use android estudio) 4.- finally -> npm run android

websasindu commented 4 days ago

This method works for me.

Close Everything. Set Java Home To Java 17 npx @react-native-community/cli@latest init AwesomeProject npx react-native run-android

and all errors gone!

K0ffeeKat commented 4 days ago

I was upgrading from 0.74.2 to 0.75.2 and got the same error on Android, here is what worked for me (using gradle-8.8-all.zip):

Hope this will be helpful

redskull-git commented 4 days ago

I was upgrading from 0.74.2 to 0.75.2 and got the same error on Android, here is what worked for me (using gradle-8.8-all.zip):

  • remove node_modules, yarn.lock and android/.gradle
  • yarn install
  • cd android && ./gradlew --stop
  • ./gradlew clean
  • npx react-native start --reset-cache in the root of the project

Hope this will be helpful

It's work, thanks

felimoles commented 4 days ago

React native 0.75.1 jdk 17 gradle 8.7 Windows 11 npm run start Error resolving plugin [id: 'com.facebook.react.settings'] , then not close emulador and npm run android work

so weird

Captura de pantalla 2024-09-09 124005

cortinico commented 1 day ago

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: https://github.com/facebook/react-native/issues/46210#issuecomment-2315210922