question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'app:bundleDebugJsAndAssets' as a task with that name already exists

See original GitHub issue

Add productFlavor: productFlavors { Beta { manifestPlaceholders = [UMENG_CHANNEL:“Beta”] buildConfigField “String”, “CHANNEL”, “"Beta"” }

    Qianmi {
        manifestPlaceholders = [UMENG_CHANNEL:"WEB"]
        buildConfigField "String", "CHANNEL", "\"WEB\""
    }

}

solution: react.gradle `gradle.projectsEvaluated { // Grab all build types and product flavors def buildTypes = android.buildTypes.collect { type -> type.name } def productFlavors = android.productFlavors.collect { flavor -> flavor.name }

// When no product flavors defined, use empty
if (!productFlavors) productFlavors.add('')
def currentBundleTask
productFlavors.each { productFlavorName ->
    buildTypes.each { buildTypeName ->
        // Create variant and source names
        def sourceName = "${buildTypeName}"
        def targetName = "${sourceName.capitalize()}"
        if (productFlavorName) {
            sourceName = "${productFlavorName}${targetName}"
        }

        // React js bundle directories
        def jsBundleDirConfigName = "jsBundleDir${targetName}"
        def jsBundleDir = elvisFile(config."$jsBundleDirConfigName") ?:
                file("$buildDir/intermediates/assets/${sourceName}")

        def resourcesDirConfigName = "jsBundleDir${targetName}"
        def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
                file("$buildDir/intermediates/res/merged/${sourceName}")
        def jsBundleFile = file("$jsBundleDir/$bundleAssetName")

        // Bundle task name for variant
        def bundleJsAndAssetsTaskName = "bundle${targetName}JsAndAssets"
        if(currentBundleTask == null){
            currentBundleTask = tasks.create(
                    name: bundleJsAndAssetsTaskName,
                    type: Exec) {
                group = "react"
                description = "bundle JS and assets for ${targetName}."

                // Create dirs if they are not there (e.g. the "clean" task just ran)
                doFirst {
                    jsBundleDir.mkdirs()
                    resourcesDir.mkdirs()
                }

                // Set up inputs and outputs so gradle can cache the result
                inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
                outputs.dir jsBundleDir
                outputs.dir resourcesDir

                // Set up the call to the react-native cli
                workingDir reactRoot

                // Set up dev mode
                def devEnabled = !targetName.toLowerCase().contains("release")
                if (Os.isFamily(Os.FAMILY_WINDOWS)) {
                    commandLine "cmd", "/c", "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
                            "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
                } else {
                    commandLine "react-native", "bundle", "--platform", "android", "--dev", "${devEnabled}",
                            "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir
                }

                enabled config."bundleIn${targetName}" ?: targetName.toLowerCase().contains("release")
            }
        }
        // Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
        currentBundleTask.dependsOn("merge${targetName}Resources")
        currentBundleTask.dependsOn("merge${targetName}Assets")

        runBefore("processArmeabi-v7a${targetName}Resources", currentBundleTask)
        runBefore("processX86${targetName}Resources", currentBundleTask)
        runBefore("processUniversal${targetName}Resources", currentBundleTask)
        runBefore("process${targetName}Resources", currentBundleTask)
    }
}

} `

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AndrewJackcommented, Apr 14, 2016

Cannot reproduce with the steps and it’s unclear what the fix is? Could you either submit a pull request with the fix or add more information?

0reactions
ghostcommented, Jun 4, 2016

@charpeni tells me to close this issue. If you think it should still be opened let us know why.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot add task 'bundleDebugJsAndAssets' as a ... - GitHub
Cannot add task 'bundleDebugJsAndAssets' as a task with that name already exists. * Try: Run with --stacktrace option to get the stack trace....
Read more >
Building React Native Android app causes error "Cannot add ...
Cannot add task ':app:prepareAwesomeProjectReactNativeLocalizationUnspecifiedLibrary' as a task with that name already exists. Doing a ...
Read more >
Cannot Add Task 'wrapper' as a Task with That Name ... - Sentry
Learn what causes "Error: Android/Gradle/Cannot add task 'wrapper' as a task with that name already exists."
Read more >
Appcenter Codepush integration. Cannot add task ...
Coding example for the question Appcenter Codepush integration. Cannot add task 'bundleDebugJsAndAssets' as a task with that name already exists-React Native.
Read more >
Implementing CodePush in React Native | by Song Cho
CodePush is an App Center cloud service by Microsoft which allows ... Cannot add task 'bundleDebugJsAndAssets' as a task with that name already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found