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

75,052

Solution 1

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

Solution 2

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.

Solution 3

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

Solution 4

Just using ./gradlew --stop and then ./gradlew assembleRelease worked for me.

Solution 5

I had the same problem, the solution was :

cd to yourApp/android folder

run this

./gradlew --stop

and then

./gradlew assembleRelease

This gonna build your app.

After build is done, go to see your application(apk).

android\app\build\outputs\apk\release

Share:
75,052
Hamid
Author by

Hamid

Cooking mobile stuff with JavaScript, TypeScript, react-native and Swift

Updated on July 20, 2022

Comments

  • Hamid
    Hamid almost 2 years

    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.

  • abbasalim
    abbasalim over 5 years
    this worked for build debug but './gradlew assembleRelease' give me errors still
  • Will Goodhew
    Will Goodhew over 5 years
    WHen I run this in my cli it is successfully building but the APK is unsigned and when I try and sign the APK via Android studio I am getting the error above
  • Daniel
    Daniel almost 5 years
    The above almost worked for me, but when I run the build, I get: Task 'bundleReleaseJsAndAssets' not found in root project
  • Sahin Elidemir
    Sahin Elidemir almost 5 years
    just ./gradlew assembleRelease -x bundleReleaseJsAndAssets saved me. Thx
  • hannojg
    hannojg over 4 years
    They changed to a new npm package npmjs.com/package/@sentry/react-native which I completely missed!
  • Anuj
    Anuj over 4 years
    Getting Task :react-native-firebase-analytics:verifyReleaseResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':react-native-firebase-analytics:verifyReleaseResources'.
  • Liam Kernighan
    Liam Kernighan almost 4 years
    If you run Windows 10, use cmd with administrator rights (no git bash), make sure that you're using the actual version of @react-native-community/cli, that directory android/app/src/main/assets exists and use yarn react-native bundle instead of react-native bundle
  • punjabi4life
    punjabi4life over 3 years
    install has 3 l in yours
  • Adriatik Gashi
    Adriatik Gashi over 3 years
    @punjabi4life didn't saw that 😂
  • Chanaka Amarasinghe
    Chanaka Amarasinghe almost 3 years
    This helps a lot