When I run ./gradlew assembleRelease
build is failed with this error:
Error:Execution failed for task \':app:bundleReleaseJsAndAsse
I did it like this and it works:
rm -rf node_modules
)npm installl
or yarn install
./gradlew clean
&& ./gradlew app:assembleRelease
or ./gradlew app:assembleDebug
First:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
finally build:
./gradlew assembleRelease -x bundleReleaseJsAndAssets
Looks like you haven't made a js bundle so please make a bundle first by using command :-
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
then in your project directory
cd android
Clean your gradle
./gradlew clean
and make a build finally
./gradlew assembleDebug
Try this. Hope it will helps you.
I was using the wrong image size (i.e image@5x.png) which caused me this problem. When I deleted that image@5x.png file...it worked!!
Just using ./gradlew --stop
and then ./gradlew assembleRelease
worked for me.
As of RN 0.58, for CI builds the commands is as follows:
First create directories:
mkdir -p app/build/generated/assets/react/production/release/ && mkdir -p app/build/generated/res/react/production/release
Next:
node ../node_modules/react-native/local-cli/cli.js bundle --platform android --dev false --entry-file index.android.js --bundle-output app/build/generated/assets/react/production/release/index.android.bundle --assets-dest app/build/generated/res/react/production/release --max-workers 1 --reset-cache
Also you may also want to add for your production builds according to this;
--minify true
Taken from RN's source
NOTE: We added --max-workers 1
not to deplete CI resources since they are limited to lower numbers (mem&cpu).