I have encounter the same problem and spent 2 days solving this error. For me the problem was the environment setup, I have work on other projects and I have installed jdk 24 which react native does not support.. I followed the docs, downgrade jdk to v17 and its working fine now. Click here - https://reactnative.dev/docs/set-up-your-environment