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 · 99 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)

@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

@jjoaovitor7
Copy link

jjoaovitor7 commented Nov 17, 2024

I was with this problem when upgrading from 0.75.2 to 0.76.2, and none of these fixed for me, but I was able to fix with:

  • using openjdk 17.0.2, Android Gradle Plugin 8.6.0 (android/build.gradle) and Gradle 8.10.2 (gradle-wrapper.properties);
  • changing in babel.config.js from module:metro-react-native-babel-preset to module:@react-native/babel-preset;
  • changing ndkVersion to "27.2.12479018", kotlin_version to "2.0.0" and buildToolsVersion to "35.0.0" in android/build.gradle;
  • migrating all *.java files to *.kt files and adding apply plugin: "org.jetbrains.kotlin.android" in android/app/build.gradle;
  • update all deps and add the libs react-native-community/cli and @react-native-community/cli-platform-android;
  • and finally running gradlew clean, gradlew build and gradlew assembleRelease.

@wufeng110226
Copy link

I have a better way, It seems to be caused by folder,
'Could not move temporary workspace (abcxxx-xxx-xxx) to immutable location (abc)'. So lets change it.
It worked

@alexu96
Copy link

alexu96 commented Nov 19, 2024

Hi Team, I tried all possible ways to fix this based on above comments but unfortunately nothing worked !
This issue exists only in Windows OS. I verified with Mac OS & it's working fine.
Requesting team to fix this asap !

cc- @cortinico

@suneelx
Copy link

suneelx commented Nov 19, 2024

Hi Team, I tried all possible ways to fix this based on above comments but unfortunately nothing worked ! This issue exists only in Windows OS. I verified with Mac OS & it's working fine. Requesting team to fix this asap !

cc- @cortinico

nah issue exist in macos as well. m3 pro, sequoia 15.1

@alexu96
Copy link

alexu96 commented Nov 19, 2024

Hi Team, I tried all possible ways to fix this based on above comments but unfortunately nothing worked ! This issue exists only in Windows OS. I verified with Mac OS & it's working fine. Requesting team to fix this asap !
cc- @cortinico

nah issue exist in macos as well. m3 pro, sequoia 15.1

Mine is M1 pro, Sequoia 15.0

@lihappy
Copy link

lihappy commented Nov 21, 2024

In my case, I stopped the "yarn start" command in terminal, and gradle sync again in Android Studio, the errors gone.

@exp0nat

This comment was marked as off-topic.

cortinico added a commit to cortinico/react-native that referenced this issue Nov 29, 2024
Summary:
This should mitigate this particular issue we're seeing on Windows:
- facebook#46210

Changelog:
[Android] [Changed] - Gradle to 8.11.1

Differential Revision: D66600321
facebook-github-bot pushed a commit that referenced this issue Dec 2, 2024
Summary:
Pull Request resolved: #48026

This should mitigate this particular issue we're seeing on Windows:
- #46210

Changelog:
[Android] [Changed] - Gradle to 8.11.1

Reviewed By: javache

Differential Revision: D66600321

fbshipit-source-id: d58437485222e189d90bcf4d6b41ca956449ed22
@cortinico
Copy link
Contributor

cortinico commented Dec 3, 2024

Just a heads up that Gradle 8.11.1 got released which should mitigate this issue.

If you're having this problem could you try to upgrade Gradle version with:

cd android
./gradlew wrapper --gradle-version=8.11.1 --distribution-type=all
./gradlew clean

After that, can you report back if the issue persists?

@nithronium
Copy link

Just a heads up that Gradle 8.11.1 got released which should mitigate this issue.

If you're having this problem could you try to upgrade Gradle version with:

cd android
./gradlew wrapper --gradle-version=8.11.1 --distribution-type=all
./gradlew clean

After that, can you report back if the issue persists?

After spending many hours on debugging a lot of different stuff, I can confirm that this solved the problem for me. Thank you @cortinico

@vedantb2
Copy link

I just restarted vscode and it seems to have fixed it

cipolleschi pushed a commit that referenced this issue Dec 16, 2024
Summary:
Pull Request resolved: #48026

This should mitigate this particular issue we're seeing on Windows:
- #46210

Changelog:
[Android] [Changed] - Gradle to 8.11.1

Reviewed By: javache

Differential Revision: D66600321

fbshipit-source-id: d58437485222e189d90bcf4d6b41ca956449ed22
@nhatduong-agilityio
Copy link

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

Does anyone have problems running ./gradlew clean?
Screenshot_84

@cipolleschi
Copy link
Contributor

@nhatduong-agilityio have you run yarn install? the error message says that the path <your_app>\node_modules\@react-native\gradle-plugin does not exists. This usually happens because you have not run yarn install and therefore there is no node_modules folder materialized

@nhatduong-agilityio
Copy link

@cipolleschi I have handled the problem. I install more gradle-plugin then delete package lock, delete node_module, then yarn install again, and run command ./gradlew clean before run react-native android. Thanks

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

Work for me

@jayesh-vyas
Copy link

This error occurred when i was using npx react-native run-android but it worked when i used npm run android

@KHadham
Copy link

KHadham commented Dec 28, 2024

the weird thing is ,after all unworking solution out there
restarting my machine solve this problem

android/settings.gradle' line: 4

* What went wrong:
Error resolving plugin [id: 'com.facebook.react.settings']
> Could not read workspace metadata from

@meshboy88
Copy link

I Found a solution. I'm using RN CLI: 0.76.5

  1. Open the folder you want your app at VS Code
  2. create app with: npx @react-native-community/cli init nameofyourapp
  3. Run your emulator. Example: emulator -avd Pixel_4a_API_35
  4. First build MUST be with android and not with start. Example: yarn android.

This is working consistently for me.

@DewantiV
Copy link

DewantiV commented Jan 3, 2025

just delete node_modules folder = > npm install => npm start -- --reset-cache => npm run android => done

cipolleschi pushed a commit that referenced this issue Jan 8, 2025
Summary:
Pull Request resolved: #48026

This should mitigate this particular issue we're seeing on Windows:
- #46210

Changelog:
[Android] [Changed] - Gradle to 8.11.1

Reviewed By: javache

Differential Revision: D66600321

fbshipit-source-id: d58437485222e189d90bcf4d6b41ca956449ed22
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