facebook / react-native

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

How to initialize a react-native app of version 0.75.2 in year 2024? #46192

Closed burakkbilginn closed 2 weeks ago

burakkbilginn commented 2 weeks ago

Description

I am trying to create a react-native app with latest version (0.75.2), but it gives error.

Steps to reproduce

I created the project with npx @react-native-community/cli init newapp. Then I start the project with yarn start command. Then when I type yarn android, it downloads gradle 8.8 as written in gradle properties (distributionUrl=https://services.gradle.org/distributions/gradle-8.8-all.zip). Then the ERROR comes.

FAILURE: Build failed with an exception.

* Where:
Settings file 'C:\Users\JOHN\Desktop\react\newapp\android\settings.gradle' line: 2

* What went wrong:
Error resolving plugin [id: 'com.facebook.react.settings']
> java.io.UncheckedIOException: Could not move temporary workspace (C:\Users\JOHN\Desktop\react\newapp\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-d380c3b5-5c8f-4497-a8a6-a9f1675d5c36) to immutable location (C:\Users\JOHN\Desktop\react\newapp\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10) 

React Native Version

0.75.2

Affected Platforms

Runtime - Android, Build - Windows

Output of npx react-native info

System:
  OS: Windows 10 10.0.19045
  CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1255U
  Memory: 16.19 GB / 31.75 GB
Binaries:
  Node:
    version: 20.10.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 3.6.4
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 10.2.3
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK: Not Found
IDEs:
  Android Studio: AI-231.9392.1.2311.11255304
  Visual Studio: Not Found
Languages:
  Java: 17.0.9
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: 0.75.2
  react-native-windows: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

FAILURE: Build failed with an exception.

* Where:
Settings file 'C:\Users\JOHN\Desktop\react\newapp\android\settings.gradle' line: 2

* What went wrong:
Error resolving plugin [id: 'com.facebook.react.settings']
> java.io.UncheckedIOException: Could not move temporary workspace (C:\Users\JOHN\Desktop\react\newapp\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10-d380c3b5-5c8f-4497-a8a6-a9f1675d5c36) to immutable location (C:\Users\JOHN\Desktop\react\newapp\android\.gradle\8.8\dependencies-accessors\569c8b261a8a714d7731d5f568e0e5c05babae10)

Reproducer

https://the_app_is_too_big_to_make_snack

Screenshots and Videos

No response

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

Same error

deepanshushuklad11 commented 2 weeks ago

@burakkbilginn @redskull-git Did you try clearing the .gradle cache and rebuilding again

lq9958 commented 2 weeks ago

@burakkbilginn @redskull-git Did you try clearing the .gradle cache and rebuilding again

Switching Gradle versions didn't help, and neither did the node_modules or .gradle directories.

gaurav4332 commented 2 weeks ago

I created a project on React Native 0.75.2. The Android version runs fine in VS Code, but when I try to run iOS, it only builds without launching. However, it works properly when run through Xcode. Has anyone else faced this issue?

redskull-git commented 2 weeks ago

@burakkbilginn @redskull-git Did you try clearing the .gradle cache and rebuilding again

It doesn't work. I tried another computer, it works probably.

MalekZishan commented 2 weeks ago

✖ Copying template error Error: Couldn't find the "/var/folders/nc/z2lrr5v566zc7znqwzzwtvy80000gn/T/rncli-init-template-ME19un/node_modules/react-native/template.config.js file inside "react-native" template. Please make sure the template is valid. Read more: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template. Error: Error: Couldn't find the "/var/folders/nc/z2lrr5v566zc7znqwzzwtvy80000gn/T/rncli-init-template-ME19un/node_modules/react-native/template.config.js file inside "react-native" template. Please make sure the template is valid. Read more: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template why ? with new version 0.75

cipolleschi commented 2 weeks ago

Hi all, thanks for trying the new version of React Native.

As of today, it should be possible to create a new app doing:

npx react-native@latest init <YourAppName> --version latest

or

npx @react-natve-community/cli@latest init <YourAppName> --version latest

Could yo please try these commands out and report whether they are working or not?

If they are not working can you try to run

npx react-native@0.74.5 init <YourAppName> --version 0.74.5

To see if you are able to create a new React Native app using the older version?

blakef commented 2 weeks ago

eact-native

There error is because the CLI is trying to install the template from react-native instead of @react-native-community/template. Follow @cipolleschi's guide for the correct CLI commands.

I think this discussion needs to move to https://github.com/react-native-community/cli/issues

gopalprabhu commented 2 weeks ago

Same Error