Not able to make release APK React Native Android

2020-08-05 10:47发布

问题:

i want to make release for android application in react native so when i generate build i got below error message like

Error:Execution failed for task ':app:bundleReleaseJsAndAssets'.

A problem occurred starting process 'command 'node''

see attachment also

any idea how can i solve this ? your all suggestions are appreciable

回答1:

After spending 2 days I resolved it, Please follow the below steps:-

1) Stop Running Gradle

 $ cd RectNatoveProjectName & cd android  (Open your project and go to android folder)  
 $ ./gradlew --stop (Run this command to stop old running Gradle service )

2) Update the android app build gradle

project.ext.react = [
        nodeExecutableAndArgs : ["/usr/local/bin/node"]
];

3) Get Node details

$ which node 

> (Result will be like "/usr/username/.nvm/versions/node/v10.7.0/bin/node")

4) Link node (very imp step copy the above result in step 3)

- ln -s /usr/username/.nvm/versions/node/v10.7.0/bin/node /usr/local/bin/node

5) If Step - 4 return file exist - then to go the folder /usr/local/bin/ and delete the "node" file and perform the step -4 again.

6) If Step - 4 run successfully then this node issue will be resolved.



回答2:

It can have following possible solutions:
1] You need to change the node executable path in your build.gradle(i.e android/app/build.gradle) file as follows:

project.ext.react = [
        nodeExecutableAndArgs : ["/usr/local/bin/node"]
];

Or
2] You need to close your Android Studio and need to run below command from project root directory:

cd android
./gradlew assembleRelease

Or
3] You need to simply run "./gradlew --stop" command and then run "./gradlew assembleRelease" command



回答3:

Add the below following code in app/build.gradle at the end of the file.

 afterEvaluate{
    android.applicationVariants.all { variant ->
        variant.ext.bundleJsAndAssets.enabled = false
     }
   }