Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native assembleRelease fails for task ':app:bundleReleaseJsAndAssets'

When I run ./gradlew assembleRelease build is failed with this error:

Error:Execution failed for task ':app:bundleReleaseJsAndAssets. 
> A problem occurred starting process 'command 'node'

I searched on the internet and found some topics about it, but I couldn't solve my problem.

React-Native version: 0.54.0

EDIT:
Now I'm running ./gradlew assembleRelease --info from the terminal instead of Android Studio and I get different error.
Here is the result:

> Task :app:processReleaseResources
Putting task artifact state for task ':app:processReleaseResources' into context took 0.007 secs.
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
Executing task ':app:processReleaseResources' (up-to-date check took 0.035 secs) due to:
  Task has failed previously.
All input files are considered out-of-date for incremental task ':app:processReleaseResources'.
Unable do incremental execution: full task run
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
file or directory '**/android/app/libs', not found
file or directory '**/node_modules/appcenter-crashes/android/libs', not found
file or directory '**/node_modules/appcenter-analytics/android/libs', not found
file or directory '**/node_modules/appcenter/android/libs', not found
file or directory '**/node_modules/react-native-interactable/lib/android/libs', not found
file or directory '**/node_modules/react-native-navigation/android/app/libs', not found
Aapt2QueuedResourceProcessor is using **/Android/sdk/build-tools/26.0.2/aapt2
Failed to execute aapt
com.android.ide.common.process.ProcessException: Failed to execute aapt
*
*
*
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> Failed to execute aapt


It seems gradle is looking for libs folder in all modules, but there are no libs folders in the node modules. It's true, but I don't know why gradle is looking for libs folder.

like image 362
Hamid Avatar asked Mar 27 '18 12:03

Hamid


3 Answers

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
like image 106
anibalajt Avatar answered Nov 17 '22 06:11

anibalajt


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.

like image 21
Kartik Shah Avatar answered Nov 17 '22 06:11

Kartik Shah


For me the creating the bundle failed, but I noticed this comment by Sahin Elidemir:

just ./gradlew assembleRelease -x bundleReleaseJsAndAssets saved me.

It almost worked for me. What worked at the end was (notice the app:, which for me it fails without, and a clean for good measure):

./gradlew clean app:assembleRelease -x bundleReleaseJsAndAssets
like image 20
MikeL Avatar answered Nov 17 '22 06:11

MikeL