In case you are still facing similar issue, and the above solutions did not work, here is a solution that worked for me:
First,I ran the following command to identify which file was the root cause:
node ./node_modules/@react-native-community/cli/build/bin.js config
This returned the following, indicating an issue with the AndroidManifest.xml of my react-native-screens dependency. Specifically, the package declaration was missing:
error Failed to build the app: No package name found. Found errors in <root-path>\node_modules\react-native-screens\android\src\main\AndroidManifest.xml.
Please not that the issue might be on another dependency.
Once you've identified the issue, just add the necessary package i.e
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.swmansion.rnscreens"> </manifest>
Note that I also downgraded my node version to 18,although it is not a mandatory action.