'app:bundleDebugJsAndAssets' as a task with that name already exists
See original GitHub issueAdd 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:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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?
@charpeni tells me to close this issue. If you think it should still be opened let us know why.