{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react-native/issues/6967","repository_url":"https://api.github.com/repos/facebook/react-native","labels_url":"https://api.github.com/repos/facebook/react-native/issues/6967/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react-native/issues/6967/comments","events_url":"https://api.github.com/repos/facebook/react-native/issues/6967/events","html_url":"https://github.com/facebook/react-native/issues/6967","id":148246368,"number":6967,"title":"'app:bundleDebugJsAndAssets' as a task with that name already exists","user":{"login":"wv1124","id":2101637,"avatar_url":"https://avatars.githubusercontent.com/u/2101637?v=3","gravatar_id":"","url":"https://api.github.com/users/wv1124","html_url":"https://github.com/wv1124","followers_url":"https://api.github.com/users/wv1124/followers","following_url":"https://api.github.com/users/wv1124/following{/other_user}","gists_url":"https://api.github.com/users/wv1124/gists{/gist_id}","starred_url":"https://api.github.com/users/wv1124/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wv1124/subscriptions","organizations_url":"https://api.github.com/users/wv1124/orgs","repos_url":"https://api.github.com/users/wv1124/repos","events_url":"https://api.github.com/users/wv1124/events{/privacy}","received_events_url":"https://api.github.com/users/wv1124/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react-native/labels/Android","name":"Android","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-14T04:03:58Z","updated_at":"2016-04-14T16:25:43Z","closed_at":null,"body":"Add productFlavor:\r\n productFlavors {\r\n        Beta {\r\n            manifestPlaceholders = [UMENG_CHANNEL:\"Beta\"]\r\n            buildConfigField \"String\", \"CHANNEL\", \"\\\"Beta\\\"\"\r\n        }\r\n\r\n        Qianmi {\r\n            manifestPlaceholders = [UMENG_CHANNEL:\"WEB\"]\r\n            buildConfigField \"String\", \"CHANNEL\", \"\\\"WEB\\\"\"\r\n        }\r\n}\r\n\r\nsolution:\r\nreact.gradle\r\n`gradle.projectsEvaluated {\r\n    // Grab all build types and product flavors\r\n    def buildTypes = android.buildTypes.collect { type -> type.name }\r\n    def productFlavors = android.productFlavors.collect { flavor -> flavor.name }\r\n\r\n    // When no product flavors defined, use empty\r\n    if (!productFlavors) productFlavors.add('')\r\n    def currentBundleTask\r\n    productFlavors.each { productFlavorName ->\r\n        buildTypes.each { buildTypeName ->\r\n            // Create variant and source names\r\n            def sourceName = \"${buildTypeName}\"\r\n            def targetName = \"${sourceName.capitalize()}\"\r\n            if (productFlavorName) {\r\n                sourceName = \"${productFlavorName}${targetName}\"\r\n            }\r\n\r\n            // React js bundle directories\r\n            def jsBundleDirConfigName = \"jsBundleDir${targetName}\"\r\n            def jsBundleDir = elvisFile(config.\"$jsBundleDirConfigName\") ?:\r\n                    file(\"$buildDir/intermediates/assets/${sourceName}\")\r\n\r\n            def resourcesDirConfigName = \"jsBundleDir${targetName}\"\r\n            def resourcesDir = elvisFile(config.\"${resourcesDirConfigName}\") ?:\r\n                    file(\"$buildDir/intermediates/res/merged/${sourceName}\")\r\n            def jsBundleFile = file(\"$jsBundleDir/$bundleAssetName\")\r\n\r\n            // Bundle task name for variant\r\n            def bundleJsAndAssetsTaskName = \"bundle${targetName}JsAndAssets\"\r\n            if(currentBundleTask == null){\r\n                currentBundleTask = tasks.create(\r\n                        name: bundleJsAndAssetsTaskName,\r\n                        type: Exec) {\r\n                    group = \"react\"\r\n                    description = \"bundle JS and assets for ${targetName}.\"\r\n\r\n                    // Create dirs if they are not there (e.g. the \"clean\" task just ran)\r\n                    doFirst {\r\n                        jsBundleDir.mkdirs()\r\n                        resourcesDir.mkdirs()\r\n                    }\r\n\r\n                    // Set up inputs and outputs so gradle can cache the result\r\n                    inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)\r\n                    outputs.dir jsBundleDir\r\n                    outputs.dir resourcesDir\r\n\r\n                    // Set up the call to the react-native cli\r\n                    workingDir reactRoot\r\n\r\n                    // Set up dev mode\r\n                    def devEnabled = !targetName.toLowerCase().contains(\"release\")\r\n                    if (Os.isFamily(Os.FAMILY_WINDOWS)) {\r\n                        commandLine \"cmd\", \"/c\", \"react-native\", \"bundle\", \"--platform\", \"android\", \"--dev\", \"${devEnabled}\",\r\n                                \"--entry-file\", entryFile, \"--bundle-output\", jsBundleFile, \"--assets-dest\", resourcesDir\r\n                    } else {\r\n                        commandLine \"react-native\", \"bundle\", \"--platform\", \"android\", \"--dev\", \"${devEnabled}\",\r\n                                \"--entry-file\", entryFile, \"--bundle-output\", jsBundleFile, \"--assets-dest\", resourcesDir\r\n                    }\r\n\r\n                    enabled config.\"bundleIn${targetName}\" ?: targetName.toLowerCase().contains(\"release\")\r\n                }\r\n            }\r\n            // Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process\r\n            currentBundleTask.dependsOn(\"merge${targetName}Resources\")\r\n            currentBundleTask.dependsOn(\"merge${targetName}Assets\")\r\n\r\n            runBefore(\"processArmeabi-v7a${targetName}Resources\", currentBundleTask)\r\n            runBefore(\"processX86${targetName}Resources\", currentBundleTask)\r\n            runBefore(\"processUniversal${targetName}Resources\", currentBundleTask)\r\n            runBefore(\"process${targetName}Resources\", currentBundleTask)\r\n        }\r\n    }\r\n}\r\n`\r\n"},"comment":{"url":"https://api.github.com/repos/facebook/react-native/issues/comments/210034420","html_url":"https://github.com/facebook/react-native/issues/6967#issuecomment-210034420","issue_url":"https://api.github.com/repos/facebook/react-native/issues/6967","id":210034420,"user":{"login":"AndrewJack","id":798942,"avatar_url":"https://avatars.githubusercontent.com/u/798942?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewJack","html_url":"https://github.com/AndrewJack","followers_url":"https://api.github.com/users/AndrewJack/followers","following_url":"https://api.github.com/users/AndrewJack/following{/other_user}","gists_url":"https://api.github.com/users/AndrewJack/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewJack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewJack/subscriptions","organizations_url":"https://api.github.com/users/AndrewJack/orgs","repos_url":"https://api.github.com/users/AndrewJack/repos","events_url":"https://api.github.com/users/AndrewJack/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewJack/received_events","type":"User","site_admin":false},"created_at":"2016-04-14T16:25:43Z","updated_at":"2016-04-14T16:25:43Z","body":"Cannot reproduce with the steps and it's unclear what the fix is? \r\nCould you either submit a pull request with the fix or add more information?"}}