5

I am following React Native 0.67.4 instruction to generate keys and sign config before building release package. The app runs fine in Android emulator (Android Studio 2120.1.1 Patch2). But when building release package, both ./gradlew assembleRelease and ./gradlew bundleRelease has the same error as below:

Task :app:signReleaseBundle FAILED

w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
   > java.lang.NullPointerException (no error message)

Tried the following in the post:

  1. Deleted all under ./gradle and yarn run android
  2. ./gradlew clean many times

Android studio 2021.1.1 Patch2, Gradle React Native plugin version 7.2.1/(gradle 7.4.1).

Here is part of package.json:

"dependencies": {
    "@ethersproject/shims": "^5.6.0",
    "@react-native-community/toolbar-android": "^0.2.1",
    "@react-native-masked-view/masked-view": "^0.2.6",
    "@react-native-picker/picker": "^2.4.0",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/stack": "^6.1.1",
    "crypto-js": "^4.1.1",
    "ethers": "^5.6.1",
    "react": "17.0.2",
    "react-native": "0.67.4",
    "react-native-blob-util": "^0.14.1",
    "react-native-confirmation-code-field": "^7.3.0",
    "react-native-device-info": "^8.5.1",
    "react-native-easy-grid": "^0.2.2",
    "react-native-elements": "^3.4.2",
    "react-native-encrypted-storage": "^4.0.2",
    "react-native-flash-message": "^0.2.1",
    "react-native-gesture-handler": "^2.3.2",
    "react-native-get-random-values": "^1.7.2",
    "react-native-gifted-chat": "^0.16.3",
    "react-native-image-picker": "^4.7.3",
    "react-native-loading-spinner-overlay": "^3.0.0",
    "react-native-modal": "^13.0.1",
    "react-native-reanimated": "^2.5.0",
    "react-native-redash": "^16.2.3",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-safe-area-context": "^4.2.2",
    "react-native-screens": "^3.13.1",
    "react-native-vector-icons": "^9.1.0",
    "rn-alioss": "^0.2.5",
    "socket.io-client": "^4.4.1"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "7.14.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.66.2",
    "react-test-renderer": "17.0.2"
  },
user938363
  • 9,990
  • 38
  • 137
  • 303
  • After removing if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {} for release{} in /android/app/buld.gradle, the error disappears. – user938363 Apr 08 '22 at 19:39

1 Answers1

8

I was also searching for the solution to the same issue everywhere. Finally, after spending hours on it I came to a solution that finally worked for me, and I think this would solve your issue as well.

As shown in the error log we do have multiple kotlin daemon sessions running in the background.

You can check for this yourself. Go to the android folder and enter

./gradlew --status

It'll display all the running daemon processes along with the process id and its status. For now, we can only stop them.

./gradlew --stop

Now navigate to your home directory using the terminal command

cd ~


After that remove the hidden `.gradle` folder using

sudo rm -rf .gradle


Now that you've removed all the daemon cache, you're good to go with the fresh installation.

Remove the node_modules and reinstall the pacakges
For safety navigate to the android folder and perform ./gradlew clean

Now build your react-native project!

SoF
  • 729
  • 1
  • 10
  • 24
Anil Rai
  • 104
  • 2