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

后端 未结 12 2007
借酒劲吻你
借酒劲吻你 2020-12-13 02:24

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

Error:Execution failed for task \':app:bundleReleaseJsAndAsse         


        
相关标签:
12条回答
  • 2020-12-13 03:06

    I did it like this and it works:

    • Removed node modules (you can do it by running this command rm -rf node_modules)
    • Run npm installl or yarn install
    • Then run ./gradlew clean && ./gradlew app:assembleRelease or ./gradlew app:assembleDebug
    0 讨论(0)
  • 2020-12-13 03:07

    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
    
    0 讨论(0)
  • 2020-12-13 03:07

    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.

    0 讨论(0)
  • 2020-12-13 03:07

    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!!

    0 讨论(0)
  • 2020-12-13 03:10

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

    0 讨论(0)
  • 2020-12-13 03:10

    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).

    0 讨论(0)
提交回复
热议问题