React-native-code-push: Execution failed for task ':app:recordFilesBeforeBundleCommandDebug'.

Created on 26 Oct 2016  路  17Comments  路  Source: microsoft/react-native-code-push

:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
AAPT: /Users/zhangjunhou/APP/android/app/src/main/res/drawable-xxxhdpi/splash.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT: /Users/zhangjunhou/APP/android/app/src/main/res/drawable-mdpi/images_share.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT: /Users/zhangjunhou/APP/android/app/build/intermediates/exploded-aar/lucky/rn-splash-screen/unspecified/res/drawable/splash.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT: /Users/zhangjunhou/APP/android/app/src/main/res/drawable-xxhdpi/splash.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT: /Users/zhangjunhou/APP/android/app/src/main/res/drawable-hdpi/splash.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT: /Users/zhangjunhou/APP/android/app/src/main/res/drawable-xhdpi/splash.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
AAPT: /Users/zhangjunhou/APP/android/app/src/main/res/drawable-mdpi/splash.png: libpng warning: iCCP: Not recognizing known sRGB profile that has been edited
:app:recordFilesBeforeBundleCommandDebug
fs.js:951
return binding.readdir(pathModule._makeLong(path), options.encoding);
^

Error: ENOENT: no such file or directory, scandir '/Users/zhangjunhou/APP/android/app/build/intermediates/res/merged/debug'
at Error (native)
at Object.fs.readdirSync (fs.js:951:18)
at getFilesInFolder (/Users/zhangjunhou/APP/node_modules/react-native-code-push/scripts/getFilesInFolder.js:7:26)
at Object. (/Users/zhangjunhou/APP/node_modules/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js:19:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
:app:recordFilesBeforeBundleCommandDebug FAILED

FAILURE: Build failed with an exception.

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.

BUILD FAILED

Total time: 47.381 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html

  • react-native-code-push version:1.15.0-beta
  • react-native version:0.33.0
  • iOS/Android/Windows version:android
  • Does this reproduce on a debug build or release build?release and debug
  • Does this reproduce on a simulator, or only on a physical device? reproduce c
  • Repro steps and/or stack trace: react-native

Most helpful comment

@Krupen, @Ge-yuan-jun - hi!
I've reproduced project structure provided by @Krupen and got similar issue. Seems like it happens due to using non-default node_modules folder location, by default it should be located directly into project root directory (execute react-native init myapp command to investigate default project structure).
While trying to fix the issue I've done following

  1. add line nodeModulesPath="path/to/node_modules" at the end of gradle.properties file (nodeModulesPath="../../android-v2/react-native-consumer-app/node_modules/node_modules" as example). Instead of changing gradle.properties file you could also change path/to/node_modules/react-native-code-push/android/codepush.gradle file. Change code line nodeModulesPath = "../../node_modules"; to nodeModulesPath = "path/to/node_modules";
  2. Change command line arguments in path/to/node_modules/react-native/react.gradle file from "node_modules/react-native/local-cli/cli.js" to "path/to/node_modules/react-native/local-cli/cli.js"
    (as example - in ../../android-v2/react-native-consumer-app/node_modules/react-native/react.gradle file change argument from "node_modules/react-native/local-cli/cli.js" to "android-v2/react-native-consumer-app/node_modules/react-native/local-cli/cli.js")

and got this error received by react-native package after executing gradlew assembleRelease command (but provided steps works well for gradlew assembleDebug command):

`Cannot find entry file index.android.js in any of the roots: ["D:\myapp\android-v2\react-native-consumer-app"]

:app:bundleReleaseJsAndAssets FAILED`

It feels like react-native is not able to find source files needed for bundling due to unexpected project structure.

All 17 comments

physical device

Just to double check, if you do a clean and then build, this still reproduces?

I have a similar problem.
I am getting Error: Cannot find module /Users/krupenghetiya/AndroidStudioProjects/node_modules/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js when I do ./gradlew assembleRelease

I have applied plugin as below:
apply from: "../../android-v2/react-native-consumer-app/node_modules/react-native/react.gradle"
apply from: "../../android-v2/react-native-consumer-app/node_modules/react-native-code-push/android/codepush.gradle"
and it doesn't give any error, it gradle syncs and complies well.

I have a submodule(different directory) for React-Native code as I have both Android and iOS app and code management becomes easy.
My recordFilesBeforeBundleCommand.js would be at path /Users/krupenghetiya/AndroidStudioProjects/android-v2/react-native-consumer-app/node_modules/react-native-code-push/scripts/recordFilesBeforeBundleCommand.js
So how do I specify it?

i find The directory does not match
react-native-code-push/android/codepush.gradle
before file("$buildDir/intermediates/res/merged/${targetPath}")
update file("$buildDir/intermediates/res/${targetPath}")

@zhangjunhou, @Krupen, @chenpengjun, @pvsong, @lubegamark - hello! Could you please tell me _what version of Android Plugin for Gradle_ are you using? After investigation I've found, that plugin version lower than 1.3.0 makes build in a different way than version 1.3.0 or higher. For example: project with com.android.tools.build:gradle:1.2.0 plugin has $buildDir/intermediates/res/debug path after build, and project with com.android.tools.build:gradle:1.3.0 has $buildDir/intermediates/res/merged/debug. This is the reason why the fix, provided by @chenpengjun works fine.
So this issue also can be fixed by changing plugin version to com.android.tools.build:gradle:1.3.0 or higher.

@sergey-akhalkov I am using gradle 1.2.3
Thanks

@Krupen Same problem. Do you have any solutions? My gradle version is 2.2.2.

@sergey-akhalkov I have tried your pr, but it doesn't work.

@sergey-akhalkov I am using gradle 2.2.0. It is happening only after integrating code-push by Microsoft. I checked-out previous commit (without code-push) and it worked well. But now even if I remove codepush code on my latest commits, problem still persists.

@Ge-yuan-jun Work around will be to generate bundle files and put them manually in android/app/src/main/assets/index.android.bundle folder, and build using android-studio.

I use below command to generate bundle files:
react-native bundle --dev false --platform android --entry-file index.android.js \ --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
The paths will change based on your project structure Or you can create anywhere and then copy-paste it at above path.

@Krupen, @Ge-yuan-jun - hi!
I've reproduced project structure provided by @Krupen and got similar issue. Seems like it happens due to using non-default node_modules folder location, by default it should be located directly into project root directory (execute react-native init myapp command to investigate default project structure).
While trying to fix the issue I've done following

  1. add line nodeModulesPath="path/to/node_modules" at the end of gradle.properties file (nodeModulesPath="../../android-v2/react-native-consumer-app/node_modules/node_modules" as example). Instead of changing gradle.properties file you could also change path/to/node_modules/react-native-code-push/android/codepush.gradle file. Change code line nodeModulesPath = "../../node_modules"; to nodeModulesPath = "path/to/node_modules";
  2. Change command line arguments in path/to/node_modules/react-native/react.gradle file from "node_modules/react-native/local-cli/cli.js" to "path/to/node_modules/react-native/local-cli/cli.js"
    (as example - in ../../android-v2/react-native-consumer-app/node_modules/react-native/react.gradle file change argument from "node_modules/react-native/local-cli/cli.js" to "android-v2/react-native-consumer-app/node_modules/react-native/local-cli/cli.js")

and got this error received by react-native package after executing gradlew assembleRelease command (but provided steps works well for gradlew assembleDebug command):

`Cannot find entry file index.android.js in any of the roots: ["D:\myapp\android-v2\react-native-consumer-app"]

:app:bundleReleaseJsAndAssets FAILED`

It feels like react-native is not able to find source files needed for bundling due to unexpected project structure.

Closing this for now, please feel free to reopen it if the issue still reproduces or if I could help you somehow.

For us the same issue appears with gradle plugin 2.3.2
Project structure
-project-folder
-- app
-- node_modules

and i got the same behavior as sergey-alkhalkov described with the wrong path.

Hi @xMikeTx, due to react-native internal "things" (as I can remember) you probably need to use the following project structure as workaround:

--android
----app
--index.android.js
--node_modules
--package.json
...

Hi @sergey-akhalkov , thank you for the quick reply.
I feared, that would be the case :(

Thank you for your help.

I have figured this out. The gradle task packageReleaseResources must be run before recordFilesBeforeBundleCommand, then the folder /build/intermediates/bundles/release/res will be generated.

So making the recordFilesBeforeBundleCommand depend on packageReleaseResources can get this issue solved.

Hi @zijing07, thanks for reaching us and for the investigation. I've not seen this issue for a long time, I believe this PR resolves the issue, could you please confirm?

@zijing07 how/ where do you change these configs?

@waltermvp @sergey-akhalkov sorry to reply so late, here is my build.sh.

echo start build android aars
./gradlew clean
./gradlew packageReleaseResources
./gradlew assembleRelease

Every time I build an aar, I have to run packageReleaseResources task first, otherwise, the folder /build/intermediates/bundles/release/res will not be generated, which will cause the failure of recordFilesBeforeBundleCommand.

I currently have no idea this is a bug of codepush or I am using the codepush build in a wrong way. But the workaround works for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergey-akhalkov picture sergey-akhalkov  路  4Comments

SudoPlz picture SudoPlz  路  4Comments

Phredward picture Phredward  路  3Comments

chrisjrex picture chrisjrex  路  4Comments

Adr1ann picture Adr1ann  路  3Comments