microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
8.98k stars 1.47k forks source link

Task :app:generateBundledResourcesHashRelease FAILED #1578

Closed aljosa-m closed 5 years ago

aljosa-m commented 5 years ago

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

yuri-kulikov commented 5 years ago

Hey @aljosa-m, Thanks for reporting!

I created a simple app:

  1. react-native init Issue1578 --version react-native@0.57.8
  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?

yuri-kulikov commented 5 years ago

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.

mirceanis commented 5 years ago

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")
        //...
nimerfatsme commented 5 years ago

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 .

mirceanis commented 5 years ago

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

nimerfatsme commented 5 years ago

wow , thanks for quick feedback

nimerfatsme commented 5 years ago

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 <nimer.farahty@gmail.com>
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)
tejasbubane commented 5 years ago

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

v0lume commented 5 years ago

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

jpaas commented 4 years ago

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. :(

Ancy1 commented 4 years ago

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.

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

majugurci commented 3 years ago

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

Thank you, this works.

Will this ever get fixed and published, it seems strange that these 2 lines are not merged for more than 2 years?

bambang-ap commented 2 years ago

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

Thanks sir, you save my day 🙏

rusakovic commented 2 years ago

Issue still exists. Confirm.

matt-dalton commented 2 years ago

I'm also experiencing this...any suggested workarounds?

cundus commented 1 year ago

8 November 2022, issue still exist. but fixed by manually adding solustion from @mirceanis to the node_modules

dann95 commented 1 year ago

17/01/23 issue still exists.

slife518 commented 1 year ago

You need to modify two places.

56 if (variant.hasProperty("bundleJsAndAssets")) { def reactBundleTask = variant.bundleJsAndAssets jsBundleDir = reactBundleTask.generatedAssetsFolders[0].absolutePath resourcesDir = reactBundleTask.generatedResFolders[0].absolutePath jsBundleFile = file("$jsBundleDir/$bundleAssetName")

113 - // generateBundledResourcesHash.dependsOn("createBundle${targetName}JsAndAssets") 114 + generateBundledResourcesHash.dependsOn("bundle${targetName}JsAndAssets")

ShaikRizwan0343 commented 1 year ago

still facing same issue after modifying if (variant.hasProperty("bundleJsAndAssets")) { def reactBundleTask = variant.bundleJsAndAssets jsBundleDir = reactBundleTask.generatedAssetsFolders[0].absolutePath resourcesDir = reactBundleTask.generatedResFolders[0].absolutePath jsBundleFile = file("$jsBundleDir/$bundleAssetName")