Task :app:generateBundledResourcesHashRelease FAILED while building relese apk react-native - react-native

I am facing this error after installing react-native-code-push.
Task :app:generateBundledResourcesHashRelease FAILED
internal/fs/utils.js:230
throw err;
^
Error: ENOENT: no such file or directory, scandir '/home/ayush/Desktop/awsproject/android/app/build/generated/res/react/release'
at Object.readdirSync (fs.js:872:3)
at getFilesInFolder (/home/ayush/Desktop/awsproject/node_modules/react-native-code-push/scripts/getFilesInFolder.js:7:26)
at Object.<anonymous> (/home/ayush/Desktop/awsproject/node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:38:1)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/home/ayush/Desktop/awsproject/android/app/build/generated/res/react/release'
}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:generateBundledResourcesHashRelease'.
> Process 'command 'node'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 36s
52 actionable tasks: 52 executed

go to node_modules/react-native-code-push/android/codepush.gradle
It appears that the only change needed to make this work is to add 2 mkdirs() calls to the codepush gradle task, like so:
//...
if (variant.hasProperty("bundleJsAndAssets")) {z
def reactBundleTask = variant.bundleJsAndAssets
jsBundleDir = reactBundleTask.generatedAssetsFolders[0].absolutePath
resourcesDir = reactBundleTask.generatedResFolders[0].absolutePath
//add these 2 lines
new File(jsBundleDir).mkdirs()
new File(resourcesDir).mkdirs()
jsBundleFile = file("$jsBundleDir/$bundleAssetName")
//...

Related

Gets ENOTDIR error when yarn start for expo project

I activated yarn by following yarn official docs (https://yarnpkg.com/getting-started/install)
I created an expo app with yarn by following react native official docs (https://reactnative.dev/docs/environment-setup)
But when I run yarn start I get below error
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
Error: spawn ENOTDIR
at ChildProcess.spawn (node:internal/child_process:413:11)
at Object.spawn (node:child_process:700:9)
at spawn (/Users/minseok/Repository/test/.yarn/cache/cross-spawn-npm-6.0.5-2deab6c280-f893bb0d96.zip/node_modules/cross-spawn/index.js:12:24)
at run (/Users/minseok/Repository/test/.yarn/unplugged/expo-npm-46.0.10-310b54dc3f/node_modules/expo/bin/cli.js:11:12)
at Object.<anonymous> (/Users/minseok/Repository/test/.yarn/unplugged/expo-npm-46.0.10-310b54dc3f/node_modules/expo/bin/cli.js:6:1)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require$$0.Module._extensions..js (/Users/minseok/Repository/test/.pnp.cjs:20807:33)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.require$$0.Module._load (/Users/minseok/Repository/test/.pnp.cjs:20630:22) {
errno: -20,
code: 'ENOTDIR',
syscall: 'spawn'
}
How can I fix this?

How do I fix this error on my React Native Yarn

When I run yarn start this error is showing with error command failed with exit code. How can I solve this?
yarn run v1.22.18
$ node -r #babel/register ./.erb/scripts/check-port-in-use.js && yarn start:renderer
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '#babel/register'
Require stack:
- internal/preload
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at Module._preloadModules (node:internal/modules/cjs/loader:1282:12)
at loadPreloadModules (node:internal/bootstrap/pre_execution:539:5)
at prepareMainThreadExecution (node:internal/bootstrap/pre_execution:85:3)
at node:internal/main/run_main_module:7:1 {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'internal/preload' ]

* What went wrong: A problem occurred evaluating script

I'm trying to run a new React native project on an Android emulator and i get this error
FAILURE: Build failed with an exception.
Where:
Script '...\AwesomeProject\node_modules#react-native-community\cli-platform-android\native_modules.gradle' line: 213
What went wrong:
A problem occurred evaluating script.
internal/modules/cjs/loader.js:905 throw err; ^Error: Cannot find module '...\AwesomeProject\node_modules\react-native\node_modules#react-native-community\cli\build\bin.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15) at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: []}
please someone help, i trying to fix that for a long time.

Error in React Native with RealmJS- Command PhaseScriptExecution failed with a nonzero exit code

Using Node.js v12.13.0 internal/modules/cjs/loader.js:797
throw err;
^
Error: Cannot find module '/Users/ABC/Projects/ReactNative/Project ABCD'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
at Function.Module._load (internal/modules/cjs/loader.js:687:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11 { code: 'MODULE_NOT_FOUND', requireStack: [] }
Command PhaseScriptExecution failed with a nonzero exit code
It seems like you are trying to reference a module that lives somewhere else. Can we see project code and file structure?
I resolved this issue by just removing a space from project folder name.
'Project ABCD' -> 'Project_ABCD'

Cannot compile react-native-expo project

So i have a bare react-native application wherein i am using expo modules.
I am using the expo location module and getting the following error.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:361: error: cannot find symbol
new Permissions.PermissionsRequestListener() {
^
symbol: class PermissionsRequestListener
location: interface Permissions
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:502: error: cannot find symbol
mPermissions.getPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
^
symbol: method getPermission(String)
location: variable mPermissions of type Permissions
/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java:503: error: cannot find symbol
&& mPermissions.getPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
^
symbol: method getPermission(String)
location: variable mPermissions of type Permissions
Note: /home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/expo-location/android/src/main/java/expo/modules/location/taskConsumers/GeofencingTaskConsumer.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':expo-location:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 16s
at checkExecSyncError (child_process.js:607:13)
at execFileSync (child_process.js:627:13)
at runOnAllDevices (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:94:39)
at buildAndRun (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/home/amol/Desktop/AccountantComplete/CompleteCode/Accountant/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7);
So my best guess is there is an error while importing stuff from permission module.
So i have these lines in expo-permissions app level build.gradle file.
compileOnly('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
I am also using jettifier, i am guessing there is some issue with respect to transpiling code to android x.
I changed this
compileOnly('com.facebook.react:react-native:+') {
exclude group: 'com.android.support'
}
to
implementation 'com.facebook.react:react-native:+'
and everything works fine.
I would like to know exactly what is happening and if this deserves a pull request.
Any help on the same would be highly appreciated thanks.
ok, in my case I needed to raise the following versions from android/build.grade:
buildscript {
ext {
buildToolsVersion = "28.0.3" -> "29.0.2"
minSdkVersion = 21
compileSdkVersion = 28 -> 29
targetSdkVersion = 28 -> 29
}