Error: ENOENT: no such file or directory, open '/Users/me/myproject/android/app/build/intermediates/assets/debug/CodePushHash'
gradle 升级到3.2.0后编译打包结果报错
- react-native-code-push version: 5.4.2
- react-native version: 0.56.1
折腾好久,发现
I've created a new react-native 0.56.1 (gradle plugin 3.1.4) app and that stage was also skipped: :app:bundleDebugJsAndAssets SKIPPED
,
but the /build/intermediates/assets/debug/
folder was still created properly, so I guess it's now the reason.
Then I've tried gradle plugin 3.2.1 and finally reproduced the issue. (It's because Gradle Plugin 3.2 uses a new intermediates/merged_assets
directory instead of intermediates/assets
)
So if you are using gradle plugin 3.2+ it's also better to use react native 0.57.2+ for better compability.
There is a workaround for this:
In {project_dir}/node_modules/react-native-code-push/android/codepush.gradle (~86-90)
just add this three lines:
generateBundledResourcesHash = tasks.create( name: "generateBundledResourcesHash${targetName}", type: Exec) { + doFirst { + jsBundleDir.mkdirs() + } commandLine (*nodeExecutableAndArgs, "${nodeModulesPath}/react-native-code-push/scripts/generateBundledResourcesHash.js", resourcesDir, jsBundleFile, jsBundleDir, resourcesMapTempFileName) }
国外大神给的解释。方法也在其中了。记录下。
https://github.com/Microsoft/react-native-code-push/issues/1427