N Kaushik

Cannot add task 'bundleReleaseJsAndAssets_SentryUpload_6' as a task with that name already exists

September 07, 2021

Issue detail:

This issue occurs on react native projects if you are using sentry.

Complete stack trace:

FAILURE: Build failed with an exception.

* Where:
Script '/Users/nkd/Downloads/project/node_modules/@sentry/react-native/sentry.gradle' line: 72

* What went wrong:
Cannot add task 'bundleReleaseJsAndAssets_SentryUpload_6' as a task with that name already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7/userguide/command_line_interface.html#sec:command_line_warnings


Sentry failed error


This project was failing on any release bundle creation. It fails if I do ./gradlew assembleRelease or ./gradlew clean or ./gradlew bundleRelease.

Solution 1:

Try deleting android/app/build and android/build folders. Then try to run the gradle scripts again.

Solution 2:

This actually works for me. In build.gradle file, make sure that the version is calculated like this:

 def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
            def abi = output.getFilter(OutputFile.ABI)
            if (abi != null) {  // null for the universal-debug, universal-release variants
                output.versionCodeOverride =
                        defaultConfig.versionCode + versionCodes.get(abi)

I removed versionCodes.get(abi) and it starts throwing this error.

Reported issues:

Issue 1 Issue 2

Subscribe to my Newsletter