React-native-code-push: Task :app:generateBundledResourcesHashRelease FAILED

Created on 2 May 2019  路  11Comments  路  Source: microsoft/react-native-code-push

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Steps to Reproduce

I have a react native app and it fails when I try to make a build. Without CodePush the build is successful.

Expected Behavior

Build & run on Android without errors

Actual Behavior

The build fails with the following message:

> Task :app:generateBundledResourcesHashRelease FAILED
*long string*
fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/.../android/app/build/generated/assets/react/release/CodePushHash'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at /.../node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:81:16
    at addFileToManifest (/.../node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:98:9)
    at /.../node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:72:9
    at addFileToManifest (/.../node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:98:9)
    at addJsBundleAndMetaToManifest (/.../node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:70:5)
    at /.../react-native-code-push/scripts/generateBundledResourcesHash.js:61:17
    at Hash.<anonymous> (/.../node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:114:13)
    at emitNone (events.js:111:20)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:generateBundledResourcesHashRelease'.

Environment

  • react-native-code-push version: 5.6.0
  • react-native version: 0.57.8
  • gradle version: 3.2.1
  • Does this reproduce on a debug build or release build? Release build. Debug build works fine.
android bug no-response waiting-for-clarification

Most helpful comment

Ah, yes. Of course 馃槄
I was planning to create a PR for this but I needed to do some more testing first.

The code block is in https://github.com/microsoft/react-native-code-push/blob/c39fa0d31cc8ede4fb56c58a0a1e0af193fd47c7/android/codepush.gradle#L51

All 11 comments

Hey @aljosa-m,
Thanks for reporting!

I created a simple app:

  1. react-native init Issue1578 --version [email protected]
  2. cd Issue1578
  3. yarn add react-native-code-push
  4. react-native link react-native-code-push
  5. Configured release signing
  6. Set Gradle versions:
    Screenshot 2019-05-08 at 14 35 18
  7. react-native run-android --variant=Release

Everything builds normally. Maybe you could provide us a simple reproducible demo?

Hi @aljosa-m,

I'm going to close this issue for now as I haven't heard from you in a while, unfortunately.
Please feel free to reopen it if you have any questions.

I am encountering a similar issue in the following scenario:

Due to memory constraints on the CI server I have to package the index.android.bundle file in a separate process.
Then, when time comes to build the app, the command used is:
./gradlew :app:assembleRelease -x bundleReleaseJsAndAssets

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")
        //...

hi @mirceanis
thank you for your useful feedback , i wanna just ask you where i can find this code block in order to add your recommended code .

Ah, yes. Of course 馃槄
I was planning to create a PR for this but I needed to do some more testing first.

The code block is in https://github.com/microsoft/react-native-code-push/blob/c39fa0d31cc8ede4fb56c58a0a1e0af193fd47c7/android/codepush.gradle#L51

wow , thanks for quick feedback

thnx @mirceanis
build has been success on CI environment.
i have created patch to update codepush.gradle on CI and it is success

From 1c1c9ba9c452a862cfabcbfc37a5e1aaccb72157 Mon Sep 17 00:00:00 2001
From: Nimer Farahty <[email protected]>
Date: Fri, 21 Jun 2019 12:56:41 +0300
Subject: [PATCH] fix CI Issue

---
 android/codepush.gradle | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/node_modules/react-native-code-push/android/codepush.gradle b/node_modules/react-native-code-push/android/codepush.gradle
index 3f7e373..1305b97 100644
--- a/node_modules/react-native-code-push/android/codepush.gradle
+++ b/node_modules/react-native-code-push/android/codepush.gradle
@@ -52,6 +52,11 @@ gradle.projectsEvaluated {
             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")

             generateBundledResourcesHash = tasks.create(
-- 
2.20.1 (Apple Git-117)

Ran into this issue on CI server today. Would be great if we can have this fixed rather than changing files in node_modules.

same issue. @mirceanis thanks for the solution. @yuri-kulikov this issue should be reopened

Our release process installs all node modules fresh, so the only way I can build is by building this patch into our fastlane release script. :(

Task :app:generateBundledResourcesHashRelease FAILED
internal/fs/utils.js:220
throw err;
^

Error: ENOENT: no such file or directory, scandir '/Users/rr/rr-BetaApp/android/app/build/generated/res/react/release'
at Object.readdirSync (fs.js:854:3)
at getFilesInFolder (/Users/rr/rr-BetaApp/node_modules/react-native-code-push/scripts/getFilesInFolder.js:7:26)
at Object. (/Users/rr/rr-BetaApp/node_modules/react-native-code-push/scripts/generateBundledResourcesHash.js:38:1)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
errno: -2,
syscall: 'scandir',
code: 'ENOENT',
path: '/Users/rr/rr-BetaApp/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

react-native-code-push version: 6.0.0
react-native version: 0.60.5
gradle version: 5.4.1
Does this reproduce on a debug build or release build? Release build. Debug build works fine.Its in Releasse after Androidx Migration. Jenkins build fails with this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osdnk picture osdnk  路  3Comments

DeDuckProject picture DeDuckProject  路  3Comments

Adr1ann picture Adr1ann  路  3Comments

sergey-akhalkov picture sergey-akhalkov  路  4Comments

panarasi picture panarasi  路  4Comments