[Android] Error: Duplicate resources

[x] Review the documentation: https://facebook.github.io/react-native
[x] Search for existing issues: https://github.com/facebook/react-native/issues
[x] Use the latest React Native release: https://github.com/facebook/react-native/releases

Environment
React Native Environment Info:
System:
  OS: macOS 10.14
  CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
  Memory: 103.10 MB / 8.00 GB
  Shell: 3.2.57 - /bin/bash
Binaries:
  Node: 8.12.0 - /usr/local/bin/node
  Yarn: 1.0.1 - /usr/local/bin/yarn
  npm: 6.4.1 - /usr/local/bin/npm
  Watchman: 4.7.0 - /usr/local/bin/watchman
SDKs:
  iOS SDK:
    Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
  Android SDK:
    API Levels: 16, 17, 19, 21, 23, 24, 25, 26, 27, 28
    Build Tools: 19.1.0, 20.0.0, 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.0, 27.0.1, 27.0.3, 28.0.0, 28.0.0, 28.0.2, 28.0.3
    System Images: android-16 | ARM EABI v7a, android-16 | MIPS, android-16 | Intel x86 Atom, android-16 | Google APIs Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-26 | Google Play Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-P | Google APIs Intel x86 Atom, android-P | Google Play Intel x86 Atom
IDEs:
  Android Studio: 3.2 AI-181.55<IP_ADDRESS>56338
  Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
  react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728
  react-native: 0.57.4 => 0.57.4
npmGlobalPackages:
  babel-preset-react-native: 4.0.0
  react-native-cli: 2.0.1
  react-native-create-library: 3.1.2
  react-native-git-upgrade: 0.2.7

Description
I'm not able to create a release apk with the PNG image  in Android. But can able to create a release apk when there is no PNG image in it. Here is the error I'm getting while generating the release build
[drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/src/main/res/drawable-mdpi/assets_mario.png	[drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/build/generated/res/react/release/drawable-mdpi-v4/assets_mario.png: Error: Duplicate resources
:app:mergeReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeReleaseResources'.
> [drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/src/main/res/drawable-mdpi/assets_mario.png	[drawable-mdpi-v4/assets_mario] /Users/jeffreyrajan/Tutorials/RN/errorCheck/android/app/build/generated/res/react/release/drawable-mdpi-v4/assets_mario.png: Error: Duplicate resources

* 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

Reproducible Demo

Create a app - react-native init demo
Create a assets folder in the project root folder.
Add a PNG image inside the assets folder.
Now implement a image component with the above PNG image.
Now bundle it using the cmd
 react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
Then generate release apk using Generate Signed APK

check this https://github.com/facebook/react-native/issues/19239#issuecomment-414564404
You need to remove drawable folder image if there is any?

@ZeroCool00 wont that affect the images in Android?

@ZeroCool00 @mkchx I checked with both of your answer, its working. Thanks a lot guys :)

Hi all how will we able to get this done with jenkins job. As it will do npm install always which override this change in react.gradle file. We can create build on android studio for android but not possible on jenkins.

Hi @vivek-walecha-657 I haven't tried this but you can try this command while creating offline bundling
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle

@jeffreyrajanofficial Thanx for writing, the solution you have provided will help if we go and change react.gradle file. But I don't want to make the release by changing the react.gradle file every time i do npm install everywhere.

@jeffreyrajanofficial  Can you please tell which version(latest lower than this or higher than this) is working fine, without this issue. Because release notes don't tell anything that this issue is resolved.

Things are sorted now in RN > 57 react.gradle file automatically creates the bundle.
for creating a release build you dont need to run the npm run build:android:release

Remove the files you might have on:
android/app/src/main/res/drawable-mdpi/
android/app/src/main/res/drawable-xhdpi/
android/app/src/main/res/drawable-xxhdpi/
Run Build again, This fixed the issue for me.

I was still seeing this in RN0.58.x and it continues in RN0.59.x - are we doing something wrong here or is this really a bug?
I continue to have success with the workaround from @mkchx encoded in patch form in the patches directory for use with the patch-package module and this patch (updated for RN0.59.1)
react-native+0.59.1.patch.txt

If you have extra resources added in custom folders, you might want to try something like this:
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/${resSuffix}");
            ant.move(file: originalDir, tofile: destDir);
        }
    }
    moveFunc.curry("drawable-ldpi").call()
    moveFunc.curry("drawable-mdpi").call()
    moveFunc.curry("drawable-hdpi").call()
    moveFunc.curry("drawable-xhdpi").call()
    moveFunc.curry("drawable-xxhdpi").call()
    moveFunc.curry("drawablexxxhdpi").call()
    moveFunc.curry("raw").call()
}

But if you have dependencies that are packing their own assets, it's not working, still getting this error (edited for clarity):
Execution failed for task ':app:mergeReleaseResources'.

> [drawable-xxxhdpi-v4/node_modules_reactnavigationstack_dist_views_assets_backicon]
/[...]/android/app/src/main/res/drawable-xxxhdpi/node_modules_reactnavigationstack_dist_views_assets_backicon.png

[drawable-xxxhdpi-v4/node_modules_reactnavigationstack_dist_views_assets_backicon]
/[...]/android/app/build/generated/res/react/release/drawable-xxxhdpi/node_modules_reactnavigationstack_dist_views_assets_backicon.png:

Error: Duplicate resources

@dragosroua I see a missing hyphen in your xxxhdpi curry. Coincidentally the same leading paths with problems for you?

You beat me by 2 minutes, I was about to edit that part. Yes, everything bundles ok now, but the bit with "raw" path for custom resources might be useful for somebody.

I was still seeing this, using macOS 10.14.3 + RN 0.57.8 + Android Studio 3.3 + Gradle 4.10.3. Maybe I'm not the only one? Or maybe someone here can confirm it works so I'll dig more and fix it for myself for real.
I'm currently working around it with the "patch-package" package in combination with the attached patch based on the above comment from @mkchx (with .txt suffix appended so github would accept the attachment) in order to automagically fix it on 'npm install' after adding postinstall: patch-package to my package.json scripts.
Maybe this is useful to someone...
react-native+0.57.8.patch.txt

Pls explain me why for my react-native 0.57.5 it's doesn't work?
I created pacth file. Added to package.json. Run npm install and has as result
        def currentBundleTask = tasks.create(
            name: "bundle${targetName}JsAndAssets",
            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.deleteDir()
                jsBundleDir.mkdirs()
                resourcesDir.deleteDir()
                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

without necessary changes.

@zakabluk you'd need to post the output of your npm install, but as a guess it is because the patch-package package is very careful about version numbers. you are trying on 57.5, but the patch is against 57.8?

I usually make a pythons script for patching node_modules.
Add this as postinstall.py and add it to your postinstall script or run it with ./postinstall.py
#!/usr/bin/env python3

import os
import textwrap

def file_dir():
  return os.path.dirname(os.path.realpath(__file__))

def read_file(filename):
    '''
    Reads the specified file.

    :param filename: The file to read
    :return: The content of the specified file
    '''
    if os.path.exists(filename):
        with open(filename, "r") as file:
            return file.read()
    else:
        raise IOError("file {} not found.".format(filename))

def write_file(filename, text):
    '''
    Writes the specified text to the specified file.

    :param filename: The file to write to
    :param text: The text to write
    '''
    with open(filename, "w") as file:
        file.write(text)

def fix_android_assets():
  print("Fixing android error with duplicate assets: https://github.com/facebook/react-native/issues/22234")

  gradle_file_path = "{}/node_modules/react-native/react.gradle".format(file_dir())

  code_snippet = textwrap.indent("""\
            // Added by post_install
            // Fix for: https://github.com/facebook/react-native/issues/22234
            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                        ant.move(file: originalDir, tofile: destDir);
                    }
                }
                moveFunc.curry("ldpi").call()
                moveFunc.curry("mdpi").call()
                moveFunc.curry("hdpi").call()
                moveFunc.curry("xhdpi").call()
                moveFunc.curry("xxhdpi").call()
                moveFunc.curry("xxxhdpi").call()
            }
  """, "")

  text = read_file(gradle_file_path)

  start = text.find("doFirst", 0)
  end = text.find("}", start)
  end = text.find("\n", end) + 1

  text = text[:end] + code_snippet + text[end:]

  write_file(gradle_file_path, text)

def main():
    fix_android_assets()

if __name__ == "__main__":
    main()

Looks like a re-implementation of what you get with npm install patch-package but if python is your thing and you want to maintain more code yourself it does seem viable. I'm still using this for what it's worth, with 0.59.3 like so
react-native+0.59.3.patch.txt
@hramos - #19239 was similar (I think) and this is long-standing but appears to have a fix. Does this just need a PR for an ultimate fix or am I missing a reason why the patch used here is not viable? (I might be). If we just need a PR I could send one in...

Looks like a re-implementation of what you get with npm install patch-package but if python is your thing and you want to maintain more code yourself it does seem viable. I'm still using patch-package for what it's worth, with 0.59.3 like so
react-native+0.59.3.patch.txt
@hramos - #19239 was similar (I think) and this is long-standing but appears to have a fix. Does this just need a PR for an ultimate fix or am I missing a reason why the patch used here is not viable? (I might be). If we just need a PR I could send one in...

How to use this path  ,  thank

@ZhanRu  - https://github.com/ds300/patch-package#set-up - you just want to put that patch (with .patch extension) into the 'patches' directory in your project after installing and setting up patch-package

@ZhanRu - https://github.com/ds300/patch-package#set-up - you just want to put that patch (with .patch extension) into the 'patches' directory in your project after installing and setting up patch-package

Thank you very much

For anyone still following along, I recently integrated an external system and needed to separate my testing from production external data, which leads to using "flavors" in gradle so you can have qaDebug, stagingRelease, etc etc pointing to different external system. The patch here did not support that though, so I added flavor support, and my patch looks like this now. It lives in patches/react-native+0.59.5.patch where it is applied during npm i runs after npm install patch-package
diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle
index 4ead2b6..e0f92b7 100644
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -48,6 +48,33 @@ afterEvaluate {
                 resourcesDir.mkdirs()
             }

+            // From https://stackoverflow.com/questions/53239705/react-native-error-duplicate-resources-android
+            // Currently has no solution?
+
+            // IF you are using flavors, add flavor name to the path you move from
+            def flavorPathSegment = ""
+            android.productFlavors.all { flavor ->
+                if (targetName.toLowerCase().contains(flavor.name)) {
+                    flavorPathSegment = flavor.name + "/"
+                }
+            }
+
+            doLast {
+                def moveFunc = { resSuffix ->
+                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
+                    if (originalDir.exists()) {
+                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
+                        ant.move(file: originalDir, tofile: destDir);
+                    }
+                }
+                moveFunc.curry("ldpi").call()
+                moveFunc.curry("mdpi").call()
+                moveFunc.curry("hdpi").call()
+                moveFunc.curry("xhdpi").call()
+                moveFunc.curry("xxhdpi").call()
+                moveFunc.curry("xxxhdpi").call()
+            }
+
             // Set up inputs and outputs so gradle can cache the result
             inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
             outputs.dir(jsBundleDir)

In my case problem persists with raw directory.
Version: react-native 0.59.5
My solution:
doLast {
  def moveFunc = { resSuffix ->
    File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
    if (originalDir.exists()) {
      File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
      ant.move(file: originalDir, tofile: destDir);
    }
  }
  def moveRawFunc = { dir ->
    File originalDir = file("$buildDir/generated/res/react/release/${dir}");
    if (originalDir.exists()) {
      File destDir = file("$buildDir/../src/main/res/${dir}");
      ant.move(file: originalDir, tofile: destDir);
    }
  }
  moveFunc.curry("ldpi").call()
  moveFunc.curry("mdpi").call()
  moveFunc.curry("hdpi").call()
  moveFunc.curry("xhdpi").call()
  moveFunc.curry("xxhdpi").call()
  moveFunc.curry("xxxhdpi").call()
  moveRawFunc.curry("raw").call()
}

Regards

@Dbroqua your solution worked for me (version react-native 0.59.5). Thank you.

Very interesting - I haven't had a problem with raw - do be aware that my latest version of the patch added support for flavors. If you start doing flavors you will want that flavor-support now in both of those functions. Maybe it could be parameterized somehow so the 2 funcs aren't as repetitive but I'm not good enough at groovy to contemplate it.
I can only imagine this isn't an issue in facebook and on react-native CI because they are using BUCK and their CI builds clean every time. Does anyone have a clean reproduction of this so we can get a fix upstream?

In my case the raw directory contains some mp3 used in my application.

That might form the basis of a quick+easy repro then. I don't have assets like that (yet) but easy enough to react-native init for a repo, put some assets in then I think on the second release build (maybe even the first?) you are hosed...

@Dbroqua just a heads up, my patch was merged but your mention of raw directories being very closely related but not included in my patch is also reflected in the merge. Now that my patch is in, you may want to see what change is required for the raw directory and propose a PR with a continuation of the fix, extending it for your case?

Ok,
I will do the necessary ASAP.
Regards,
Damien

Fixed!

In my case there were files in the drawables res/drawable-* directories that were lingering from some other dev on my teams commit - I was getting a "Error: Duplicate resources" pointing at those file names - I deleted the files from drawables and everything works fine 👍

Mapsy's answer should help https://stackoverflow.com/a/52750886
So basically you edit the /node_modules/react-native/react.gradle file
and add the doLast right after the doFirst block, manually.
doFirst { ... }
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
            ant.move(file: originalDir, tofile: destDir);
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

not working for me.

@Nextt1 you'll need to open a new issue - with a reproducible test case in a public repo if at all possible - and perhaps propose a new PR. This issue was closed by my PR and then an additional one (handling a case my first PR did not handle well) was also merged, so we've all moved on and I think it's working for most so this issue is not likely to get attention.

Hey everyone - the PR I proposed and had merged apparently causes a regression - https://github.com/facebook/react-native/issues/25325 - I'm investigating but if there are any gradle gurus here that now how to fix this issue without causing that regression, help would be appreciated - thanks!

Okay, the related PR here is going to have a "revert PR" - it causes a regression, and the underlying issue that caused this problem was bad documentation really.
Here's the thing: you should never copy things into the src directory during a build really. You need to copy things into intermediates and generated etc. If you have already copied things into src (from previous builds using this patch, or from a react-native bundle command): you need to clear those out so your src/main/res directory is clean - only real assets from your project
Now, to build an APK with an offline bundle - even in dev so you can run it on API < 17 you should do things differently than everyone on the web recommends (or you'll have this problem).
What you want is this in your android/app/build.gradle:
project.ext.react = [

        // This is what most people will need
        bundleInDebug: project.hasProperty("bundleInDebug") ? project.getProperty("bundleInDebug") : false,

        // If you use build variants it has to be like this - put your own names in there
        bundleInDevDebug: project.hasProperty("bundleInDevDebug") ? project.getProperty("bundleInDevDebug") : false,
        bundleInQaDebug: project.hasProperty("bundleInQaDebug") ? project.getProperty("bundleInQaDebug") : false,
        bundleIStagingDebug: project.hasProperty("bundleIStagingDebug") ? project.getProperty("bundleIStagingDebug") : false,
        bundleInProdDebug: project.hasProperty("bundleInProdDebug") ? project.getProperty("bundleInProdDebug") : false
]

Then you call react-native something like this - sending a gradle project property through via an environment variable:
ORG_GRADLE_PROJECT_bundleInDebug=true npx react-native run-android --variant

I was still seeing this, using macOS 10.14.3 + RN 0.57.8 + Android Studio 3.3 + Gradle 4.10.3. Maybe I'm not the only one? Or maybe someone here can confirm it works so I'll dig more and fix it for myself for real.
I'm currently working around it with the "patch-package" package in combination with the attached patch based on the above comment from @mkchx (with .txt suffix appended so github would accept the attachment) in order to automagically fix it on 'npm install' after adding postinstall: patch-package to my package.json scripts.
Maybe this is useful to someone...
react-native+0.57.8.patch.txt

Awesome! For now, it's the best answer!

I'm still seeing this in 0.59.9. @mkchx 's answer sorted out the issue for me

@juliancorrea  @scgough  just be careful with that, I followed that solution style to its full end with a PR accepted even, but after follow-on problems we needed to revert it. It's a dead-end solution. I posted full details of the recommended solution a couple comments above and can only recommend the new style. If you use my old attached patch based on @mkchx answer it will work for you, for now, but only under certain conditions - it fails in other common scenarios that your project may need in the future

Im still having trouble with this...
I can't seem to create my release APK file. I get the following error for every asset file:
[drawable-mdpi-v4/filename] /Users/me/React/myapp/android/app/src/main/res/drawable-mdpi/filename.png
[drawable-mdpi-v4/filename] /Users/me/React/myapp/android/app/build/generated/res/react/release/drawable-mdpi/filename.png: Error: Duplicate resources
I have deleted both instances of drawable-mdpi folders but the APK generation places them back and errors.
I am running the following manually to create my bundle:
react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

In my app gradle I have:
project.ext.react = [
    entryFile: "index.android.js",
    bundleInRelease: true    //I've tried true and false here
]

apply from: "../../node_modules/react-native/react.gradle"

Just as extra info - my app builds fine in debug (via react-native run-android)

I think I might have the reason/solution for my issue at least.
My old bundle command (I've used since RN 0.2.x?!) pushed the assets to the destination folder android/app/src/main/res/
I noted a post on the link below which states that > RN 57 actually needs assets pushed to the following folder:
android/app/build/intermediates/res/merged/release/
Source: https://github.com/facebook/react-native/issues/19211#issuecomment-448301870
I did the following:

deleted the drawable-mdpi assets that had been copied in to android/app/src/main/res/

updated my bundle command to use the new folder location

my APK now builds...(I'm about to test it)

In React Native 0.60.0 I've noticed that native base is also creating duplicate resources but the above workaround will not work because it's targeting raw folder.
[raw/node_modules_nativebase_dist_src_basic_icon_nbicons] C:\Projects\some-app\CLIENT\android\app\src\main\res\raw\node_modules_nativebase_dist_src_basic_icon_nbicons.json
[raw/node_modules_nativebase_dist_src_basic_icon_nbicons] C:\Projects\some-app\CLIENT\android\app\build\generated\res\react\release\raw\node_modules_nativebase_dist_src_basic_icon_nbicons.json: Error: Duplicate resources
For other users having this issue:
        doLast {
            def moveFunc = { resSuffix ->
                File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                    ant.move(file: originalDir, tofile: destDir);
                }
            }

            moveFunc.curry("ldpi").call()
            moveFunc.curry("mdpi").call()
            moveFunc.curry("hdpi").call()
            moveFunc.curry("xhdpi").call()
            moveFunc.curry("xxhdpi").call()
            moveFunc.curry("xxxhdpi").call()

            File originalDir = file("$buildDir/generated/res/react/release/raw");
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/raw");
                    ant.move(file: originalDir, tofile: destDir);
            }
        }

how can we solve this if we are using CI?

In my case problem persists with raw directory.
Version: react-native 0.59.5
My solution:
doLast {
  def moveFunc = { resSuffix ->
    File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
    if (originalDir.exists()) {
      File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
      ant.move(file: originalDir, tofile: destDir);
    }
  }
  def moveRawFunc = { dir ->
    File originalDir = file("$buildDir/generated/res/react/release/${dir}");
    if (originalDir.exists()) {
      File destDir = file("$buildDir/../src/main/res/${dir}");
      ant.move(file: originalDir, tofile: destDir);
    }
  }
  moveFunc.curry("ldpi").call()
  moveFunc.curry("mdpi").call()
  moveFunc.curry("hdpi").call()
  moveFunc.curry("xhdpi").call()
  moveFunc.curry("xxhdpi").call()
  moveFunc.curry("xxxhdpi").call()
  moveRawFunc.curry("raw").call()
}

Regards

This works!

[drawable-mdpi-v4/node_modules_reactnativemaplink_src_images_uber] /Users/umair/my-app/android/app/src/main/res/drawable-mdpi/node_modules_reactnativemaplink_src_images_uber.png	[drawable-mdpi-v4/node_modules_reactnativemaplink_src_images_uber] /Users/umair/my-app/android/app/build/generated/res/react/debug/drawable-mdpi/node_modules_reactnativemaplink_src_images_uber.png: Error: Duplicate resources

I get this error when I run react-native run-android but not when I build and run the release build. None of the above solutions work for me
RN 0.60.5

I am also having same issue and react.gradle patch won't fix it. In my case my duplicated resources are .OBJ and .MTL files, don't have any problems with image resources.

[raw/assets_res_salad_salad] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_salad_salad.mtl [raw/assets_res_salad_salad] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_salad_salad.obj: Error: Duplicate resources
[raw/assets_res_steak_steak] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_steak_steak.mtl [raw/assets_res_steak_steak] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_steak_steak.obj: Error: Duplicate resources
[raw/assets_res_salmon_salmon] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_salmon_salmon.mtl [raw/assets_res_salmon_salmon] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/src/main/res/raw/assets_res_salmon_salmon.obj: Error: Duplicate resources

@sercanov are you still trying to use the copy to src? That style was investigated and fails for known reasons, there are supported ways to build that don't place things in src - or are you trying those not-copy-to-src ways and still failing? https://github.com/facebook/react-native/issues/22234#issuecomment-504721069

hey @mikehardy actually tried both approaches, neither of them made it work in release builds. It works okay in debug mode btw.
When using not-copy-to-src way ORG_GRADLE_PROJECT_bundleInRelease=true npx react-native run-android --variant release I am getting this one;

Execution failed for task ':app:mergeArReleaseResources'.
[raw/assets_res_salad_salad] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salad_salad.mtl	[raw/assets_res_salad_salad] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salad_salad.obj: Error: Duplicate resources
[raw/assets_res_steak_steak] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_steak_steak.mtl	[raw/assets_res_steak_steak] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_steak_steak.obj: Error: Duplicate resources
[raw/assets_res_salmon_salmon] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salmon_salmon.mtl	[raw/assets_res_salmon_salmon] /Users/sercanov/Projects/ARt/diner/DinerApp/android/app/build/generated/res/react/ar/release/raw/assets_res_salmon_salmon.obj: Error: Duplicate resources

When used copy-to-src doLast way I had to clear src/main/res every time I need to get a build. Build succeeds but somehow assets weren't available in app. This may related to my code, currently investigating about it.

When switching to the not-copy-to-src way you have to clean everything out first, to make the switch. My project had lots of "litter" from a bundling perspective from the previous copy-to-src style that I had to clean out before it worked, then it worked every time.

@rahulkumar1409  this helped me in this error but it throws another error
Task :react-native-simple-download-manager:verifyReleaseResources FAILED
Do you have any idea why this happen ??

This solution worked for me.
So basically you edit the /node_modules/react-native/react.gradle file
and add the doLast right after the doFirst block, manually.
doFirst { ... }
doLast {
def moveFunc = { resSuffix ->
File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
if (originalDir.exists()) {
File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
ant.move(file: originalDir, tofile: destDir);
}
}
moveFunc.curry("ldpi").call()
moveFunc.curry("mdpi").call()
moveFunc.curry("hdpi").call()
moveFunc.curry("xhdpi").call()
moveFunc.curry("xxhdpi").call()
moveFunc.curry("xxxhdpi").call()
}

We are on react-native 0.60.5.
We're using product flavors just like @mikehardy mentioned and we had problems with the 'raw' folder just like @Dbroqua experienced.
I ended up mixing both solutions and we use this code:
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    def moveRawFunc = { dir ->
    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
    if (originalDir.exists()) {
        File destDir = file("$buildDir/../src/main/res/${dir}")
            ant.move(file: originalDir, tofile: destDir)
        }
    }

    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
    moveRawFunc.curry("raw").call()
}

This thread has been really helpful, thanks to everyone for contributing. 😄

Okay, the related PR here is going to have a "revert PR" - it causes a regression, and the underlying issue that caused this problem was bad documentation really.
Here's the thing: you should never copy things into the src directory during a build really. You need to copy things into intermediates and generated etc. If you have already copied things into src (from previous builds using this patch, or from a react-native bundle command): you need to clear those out so your src/main/res directory is clean - only real assets from your project
Now, to build an APK with an offline bundle - even in dev so you can run it on API < 17 you should do things differently than everyone on the web recommends (or you'll have this problem).
What you want is this in your android/app/build.gradle:
project.ext.react = [

        // This is what most people will need
        bundleInDebug: project.hasProperty("bundleInDebug") ? project.getProperty("bundleInDebug") : false,

        // If you use build variants it has to be like this - put your own names in there
        bundleInDevDebug: project.hasProperty("bundleInDevDebug") ? project.getProperty("bundleInDevDebug") : false,
        bundleInQaDebug: project.hasProperty("bundleInQaDebug") ? project.getProperty("bundleInQaDebug") : false,
        bundleInStagingDebug: project.hasProperty("bundleInStagingDebug") ? project.getProperty("bundleInStagingDebug") : false,
        bundleInProdDebug: project.hasProperty("bundleInProdDebug") ? project.getProperty("bundleInProdDebug") : false
]

Then you call react-native something like this - sending a gradle project property through via an environment variable:
ORG_GRADLE_PROJECT_bundleInDebug=true npx react-native run-android
(or for variants something like this ORG_GRADLE_PROJECT_bundleInDevDebug=true npx react-native run-android --variant devDebug)

Thanks for all your work on this. So, regarding bundle commands such as this:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
You're saying this is NOT recommended as a way to bundle for release? Bundling for release should now be done through commands in the gradle file?

I am getting the duplicate error only on release builds.  I'm using react-native 60.5
/release/drawable-xhdpi/node_modules_reactnavigationstack_lib_module_views_assets_backicon.png: Error: Duplicate resources
I've tried setting  bundleInDebug to true and false but with no affect.
I'm building using app center, this requires an src/main/assets/appcenter-config.json file.  I also have a src/main/assets/fonts directory as I'm using custom fonts.  Is this likely to be causing the problem?

@ARichIVC I'm guessing the problem is the file referenced in your error message.
It looks like the standard "my src/ directory is polluted from previous copy-style attempts to handle bundle packaging" problem from this original solution before we all realized that it's a dead-end solution and you need to clear src/ out of those copied things before trying the follow-on solution of doing the bundleInDebug stuff. It's all in this thread which is unfortunately unwieldy and long, but the info is in there

Thanks @mikehardy for your help .  I found it was fine to leave in the fonts etc in the assets directory but did need to delete the other bits and pieces hanging around.  Namely everything in \android\app\src\main\res\drawable-hdpi\

Note that even for fonts they should be in the right directory - an example: https://github.com/oblador/react-native-vector-icons#android which directs you to call this file which carefully copies into a non-src directory https://github.com/oblador/react-native-vector-icons/blob/master/fonts.gradle#L16 - everyone's project is different of course, but I thought it was worth mentioning

We are on react-native 0.60.5.
We're using product flavors just like @mikehardy mentioned and we had problems with the 'raw' folder just like @Dbroqua experienced.
I ended up mixing both solutions and we use this code:
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    def moveRawFunc = { dir ->
        File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/${dir}")
            ant.move(file: originalDir, tofile: destDir)
        }
    }

    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
    moveRawFunc.curry("raw").call()
}

This thread has been really helpful, thanks to everyone for contributing. 😄

it works! thank a lot! 👍

For react native 0.59.1 or greater you need to add below code in react.gradle in node_modules/react-native.
#for flavoured use below code.
def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
flavorPathSegment = flavor.name
}
}
        doLast {
            def moveFunc = { resSuffix ->
                File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}/release/drawable-${resSuffix}");
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
                    ant.move(file: originalDir, tofile: destDir);
                }
            }
            moveFunc.curry("ldpi").call()
            moveFunc.curry("mdpi").call()
            moveFunc.curry("hdpi").call()
            moveFunc.curry("xhdpi").call()
            moveFunc.curry("xxhdpi").call()
            moveFunc.curry("xxxhdpi").call()
        }

@dayachand-systematix this bad advice. That style solution was pursued to the point where it had a PR and was merged even. Then it was discovered it was the wrong direction and the PR was reverted. Would you advise people use a solution that actually caused a PR merge to be reverted? I would not. https://github.com/facebook/react-native/issues/22234#issuecomment-504721069

@mikehardy Yes I know this is not permanent solution but It is working fine. And also I can't able to use your solution because I have some some other files like splash screens and DB in res  directory.

Yes @dayachand-systematix me too:
mike@isabela:~/work/Kullki/ksocialscore/packages/public-app/android/app (lerna-import) % find . -type f |grep res
./src/main/res/drawable-xhdpi/minilogo_bw.png
./src/main/res/mipmap-xxhdpi/ic_launcher.png
./src/main/res/values-v21/styles.xml
./src/main/res/drawable-xxhdpi/minilogo_bw.png
./src/main/res/drawable-xxhdpi/kscore_splash.png
./src/main/res/drawable-hdpi/minilogo_bw.png
./src/main/res/mipmap-xxxhdpi/ic_launcher.png
./src/main/res/mipmap-hdpi/ic_launcher.png
./src/main/res/layout/launch_screen.xml
./src/main/res/drawable/background_launch.xml
./src/main/res/values/colors.xml
./src/main/res/values/styles.xml
./src/main/res/values/strings.xml
./src/main/res/mipmap-xhdpi/ic_launcher.png
./src/main/res/xml/filepaths.xml
./src/main/res/xml/react_native_config.xml
./src/main/res/drawable-mdpi/minilogo_bw.png
./src/main/res/drawable-xxxhdpi/minilogo_bw.png
./src/main/res/mipmap-mdpi/ic_launcher.png
./src/qa/res/mipmap-xxhdpi/ic_launcher.png
./src/qa/res/mipmap-xxxhdpi/ic_launcher.png
./src/qa/res/mipmap-hdpi/ic_launcher.png
./src/qa/res/values/strings.xml
./src/qa/res/mipmap-xhdpi/ic_launcher.png
./src/qa/res/mipmap-mdpi/ic_launcher.png
./src/debug/res/xml/react_native_config.xml
./src/staging/res/mipmap-xxhdpi/ic_launcher.png
./src/staging/res/mipmap-xxxhdpi/ic_launcher.png
./src/staging/res/mipmap-hdpi/ic_launcher.png
./src/staging/res/values/strings.xml
./src/staging/res/mipmap-xhdpi/ic_launcher.png
./src/staging/res/mipmap-mdpi/ic_launcher.png
./src/dev/res/mipmap-xxhdpi/ic_launcher.png
./src/dev/res/mipmap-xxxhdpi/ic_launcher.png
./src/dev/res/mipmap-hdpi/ic_launcher.png
./src/dev/res/values/strings.xml
./src/dev/res/mipmap-xhdpi/ic_launcher.png
./src/dev/res/mipmap-mdpi/ic_launcher.png

And still the suggested / not-PR-reverted solution works for me :man_shrugging:

Heya, we fixed it by removing the --asset-dest parameter:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle

@hery-finimize hi - wouldn't removing the --asset-dest parameter result in the latest assets not being bundled to the correct place...so when you create your APK there would be a danger of having missing/out of date asset files in the app?

@scgough I figured that might be the case. If so, we can selectively remove everything except for the local assets we need before building with Android Studio or whichever production tool, e.g.
find android/app/src/main/res/drawable-* \( -name launch_screen.png -o -name ic_stat_onesignal_default.png -prune \) -o -type f -exec rm {} +
Not ideal but should work until this is resolved.

This issue caused when if you have files same name, different extension in assets folder like that
back.png
back.jpg

remove one of them or rename it.

Hi,
I've tried to modify react.gradle : The build goes one step further (the app.aab is build but I can't build the APK.
I've tried to build the APK with Android Studio and there was no problem (with ou withou the patch to react.gradle).
It's quite strange for me because the process to build the APK should be the same in both cases. Am I wrong ?

This comment worked for 0.59.10. Mixed with this gist.
Thanks a lot, @dayachand-systematix !

What worked for me was a combination of two comments:
I'm pasting this here for anyone who else might need it.

@AbhishekNairOfficial where do you put this?

@AbhishekNairOfficial where do you put this?

node_modules/react-native/react.gradle.
Put this after the doFirst() block

I guess it is not the right way to workaround this problem. Because this change will be overrided on next npm install. Even, the CI will not work

Someone tried commands below ?
cd android
./gradlew clean
cd ..

It worked for me

What worked for me was a combination of two comments:
I'm pasting this here for anyone who else might need it.
def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }

                moveFunc.curry("ldpi").call()
                moveFunc.curry("mdpi").call()
                moveFunc.curry("hdpi").call()
                moveFunc.curry("xhdpi").call()
                moveFunc.curry("xxhdpi").call()
                moveFunc.curry("xxxhdpi").call()
                moveRawFunc.curry("raw").call()
            }

oh man you saved my day <3

What worked for me was a combination of two comments:
I'm pasting this here for anyone who else might need it.
def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }

                moveFunc.curry("ldpi").call()
                moveFunc.curry("mdpi").call()
                moveFunc.curry("hdpi").call()
                moveFunc.curry("xhdpi").call()
                moveFunc.curry("xxhdpi").call()
                moveFunc.curry("xxxhdpi").call()
                moveRawFunc.curry("raw").call()
            }

oh man you saved my day <3

Haha Thanks. I kept coming to this thread almost on a daily basis, so I decided to make life easier for others as well.

Removing android/app/build folder and building again worked for me.

My solution:
Delete . in /your_project/android/app/src/main/raw/res.
It 's work for me !

What worked for me was a combination of two comments:
I'm pasting this here for anyone who else might need it.
def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }

                moveFunc.curry("ldpi").call()
                moveFunc.curry("mdpi").call()
                moveFunc.curry("hdpi").call()
                moveFunc.curry("xhdpi").call()
                moveFunc.curry("xxhdpi").call()
                moveFunc.curry("xxxhdpi").call()
                moveRawFunc.curry("raw").call()
            }

thanks. it saved alot of time for me.

rm -rf ./android/app/src/main/res/drawable-*
rm -rf ./android/app/src/main/res/raw
This worked for me, you might get an error like i did that my splash screen from the Drawable folder was missing so I added it back and then it bundled fine.

Getting the same in v0.61.5  and as @wincod75 is saying, deleting raw and drawable folders isn't really a solution as all images are removed.
I get they are recreated for the release build but would be nice if they also worked when running react-native run-android --variant=release, that only works when they are in src/main it seams and then one can't build.
Anyone been able to solve on v0.61.5?

@gudbrand3 I eventually implemented the fix noted above to the "node_modules/react-native/react.gradle," file just so I could get a new build to the appstore, but this is absurd to have to do, not sure why this hasn't been fixed yet...

@wincod75 hear hear! I ended up with the same.. blah. I dont either get why it is not just included in the package until a better approach is found since people end up doing it anyway manually. Now it must be re-done for every deletion of node_modules and re npm install. #frustrating

Removing the drawable folders would not work for me since I had drawable resources that I needed to keep. My problem was with duplicate resources for everything in  the android/app/src/main/res/raw folder and files that started with nodemodules... in the inandroid/app/src/main/res/drawable` folder. This solved the problem for me:
Adding to android/app/build.gradle:
...
project.ext.react = [
    ...
    bundleInRelease        : true,
    resourcesDirRelease   : "src/release/res",
    ...
]
...

Removing everything that started with node from android/app/src/main/drawable*:
rm android/app/src/main/drawable*/node*
rm -rf android/app/src/main/raw

Clean project, DO NOT RUN THE REACT NATIVE BUNDLE COMMAND, then re-build.
Hope this helps someone!

Oh, boy. Maybe an official fix is on the way?

I commented apply from: "../../node_modules/react-native/react.gradle" in file android/app/build.gradle, it works and fine for me for a long time, but not sure is it actually safe or not

I am having the same issue.

in my case
first:  I placed the following code in node_modules/react-native/react.gradle after 'doFirst'
doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
        if (originalDir.exists()) {
            File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
            ant.move(file: originalDir, tofile: destDir);
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

second:  I deleted all contents of the folder android/app/src/main/res
may be useful for someone

Oh, boy. Maybe an official fix is on the way?

I hope so, I'm using RN 0.62.1 and ran into this issue as well.
Adding the doLast code or deleting the drawables folders solves this issue.
I'm wondering to know what's the official recommendation?
Thank you

Removing the drawable folders would not work for me since I had drawable resources that I needed to keep. My problem was with duplicate resources for everything in the android/app/src/main/res/raw folder and files that started with nodemodules... in the android/app/src/main/res/drawable folder. This solved the problem for me:
Adding to android/app/build.gradle:
...
project.ext.react = [
    ...
    bundleInRelease        : true,
    resourcesDirRelease   : "src/release/res",
    ...
]
...

Removing everything that started with node from android/app/src/main/drawable*:
rm android/app/src/main/drawable*/node*
rm -rf android/app/src/main/raw

Clean project, DO NOT RUN THE REACT NATIVE BUNDLE COMMAND, then re-build.
Hope this helps someone!

The above solution helped me find a decent answer:
Step 1:
Adding to android/app/build.gradle:
...
project.ext.react = [
    ...
    bundleInRelease        : true,
    resourcesDirRelease   : "src/release/res",
    ...
]
...

Step 2:
Run the following command to delete all node_module files.
rm -rf drawable*/node*

For anyone having the issue on non-image raw resources; I solved it by renaming the files with the same name but different extension.
My case
I had object.obj and object.mtl files. Even if the extensions are different, it threw duplicate resources error. Because android picks them up by file name. So, renaming object.mtl to object_material.mtl had finally resolved it for me.
It may be the same case for image resources too, try renaming them if you have images with identical names.

What worked for me was a combination of two comments:
I'm pasting this here for anyone who else might need it.
def flavorPathSegment = ""
android.productFlavors.all { flavor ->
if (targetName.toLowerCase().contains(flavor.name)) {
                    flavorPathSegment = flavor.name
            }
            }

            doLast {
                def moveFunc = { resSuffix ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/drawable-${resSuffix}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }
                def moveRawFunc = { dir ->
                    File originalDir = file("$buildDir/generated/res/react/${flavorPathSegment}release/${dir}")
                    if (originalDir.exists()) {
                        File destDir = file("$buildDir/../src/main/res/${dir}")
                        ant.move(file: originalDir, tofile: destDir)
                    }
                }

                moveFunc.curry("ldpi").call()
                moveFunc.curry("mdpi").call()
                moveFunc.curry("hdpi").call()
                moveFunc.curry("xhdpi").call()
                moveFunc.curry("xxhdpi").call()
                moveFunc.curry("xxxhdpi").call()
                moveRawFunc.curry("raw").call()
            }

targetName.toLowerCase().contains(flavor.name.toLowerCase()) work for me.
my flavor.name look like xxXX.

All of that dolast stuff was added in PRs #24518 and #24778, then removed again in #25363.  Does anyone know why it was removed?  This has been a LONG standing problem, and I thought they had it fixed.

In case that helps, here are a couple of one-liners from my script (for Android X issue as well):
echo "Fixing java error: package android.support.v4.widget does not exist issue with Android X"

npm install jetifier
npx jetify

echo "Fixing duplicate resources issue"
rm -rf .../android/app/src/main/res/raw

cd .../node_modules/react-native

cat <<EOT >> react_gradle.patch
121a122,137
>             doLast {
>                 def moveFunc = { resSuffix ->
>                     File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
>                     if (originalDir.exists()) {
>                         File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
>                         ant.move(file: originalDir, tofile: destDir);
>                     }
>                 }
>                 moveFunc.curry("ldpi").call()
>                 moveFunc.curry("mdpi").call()
>                 moveFunc.curry("hdpi").call()
>                 moveFunc.curry("xhdpi").call()
>                 moveFunc.curry("xxhdpi").call()
>                 moveFunc.curry("xxxhdpi").call()
>             }
>
EOT

ls -l react_gradle.patch
patch react.gradle react_gradle.patch

And this solution helped me to create a release build: https://github.com/facebook/react-native/issues/26245#issuecomment-631382817

the following 2 steps did it for me:
1. gradlew clean
2. npm install
3. gradlew bundleRelease

System:
    OS: macOS 10.15.3
    CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
    Memory: 221.64 MB / 8.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.22.4 - ~/Documents/youpendo-app-bareworkflow/node_modules/.bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.9.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    Android SDK:
      API Levels: 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7<IP_ADDRESS>92135
    Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_232 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: ^4.8.0 => 4.10.0
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

I am getting the same error. Any solution ?

can someone please share the patch file for react native 0.62.2

I've created this patch for the React Native 0.63.2. If you have 'drawable-*' folders, rename it for 'mipmap-*' instead, you can change the reference for it in the android/app/src/main/AndroidManifest.xml
Run this in the project's root to create the patch file
cat <<EOT >> react-native-0.62.3-react.gradle.patch
@@ -147,6 +147,23 @@
                 jsSourceMapsDir.mkdirs()
             }

+            doLast {
+                def moveFunc = { resFolder ->
+                    File originalDir = file("$buildDir/generated/res/react/release/${resFolder}");
+                    if (originalDir.exists()) {
+                        File destDir = file("$buildDir/../src/main/res/${resFolder}");
+                        ant.move(file: originalDir, tofile: destDir);
+                    }
+                }
+                moveFunc.curry("drawable-ldpi").call()
+                moveFunc.curry("drawable-mdpi").call()
+                moveFunc.curry("drawable-hdpi").call()
+                moveFunc.curry("drawable-xhdpi").call()
+                moveFunc.curry("drawable-xxhdpi").call()
+                moveFunc.curry("drawable-xxxhdpi").call()
+                moveFunc.curry("raw").call()
+            }
+
             // Set up inputs and outputs so gradle can cache the result
             inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
             outputs.dir(jsBundleDir)
EOT

then apply the patch with
patch node_modules/react-native/react.gradle < react-native-0.62.3-react.gradle.patch

Copy node_ modules/react-native/react.gradle to android/app/react.gradle, then modify android/app/build.gradle and android/app/react.gradle:
android/app/build.gradle
- apply from: "../../node_modules/react-native/react.gradle"
+ apply from: "./react.gradle"

android/app/react.gradle
           doFirst {
                jsBundleDir.deleteDir()
                jsBundleDir.mkdirs()
                resourcesDir.deleteDir()
                resourcesDir.mkdirs()
                jsIntermediateSourceMapsDir.deleteDir()
                jsIntermediateSourceMapsDir.mkdirs()
                jsSourceMapsDir.deleteDir()
                jsSourceMapsDir.mkdirs()
            }
+
+           doLast {
+               def moveFunc = { resSuffix ->
+                   File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
+                   if (originalDir.exists()) {
+                      File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}")
+                       ant.move(file: originalDir, tofile: destDir)
+                   }
+               }
+               def moveRawFunc = { dir ->
+                  File originalDir = file("${resourcesDir}/${dir}")
+                  if (originalDir.exists()) {
+                      File destDir = file("$buildDir/../src/main/res/${dir}")
+                      ant.move(file: originalDir, tofile: destDir)
+                  }
+              }
+
+              moveFunc.curry("ldpi").call()
+              moveFunc.curry("mdpi").call()
+              moveFunc.curry("hdpi").call()
+              moveFunc.curry("xhdpi").call()
+              moveFunc.curry("xxhdpi").call()
+              moveFunc.curry("xxxhdpi").call()
+              moveRawFunc.curry("raw").call()
+          }

Hi all! Could someone make a PR for these changes? Editing node_modules is not ideal.

Hi all,
I am using react-native 0.63.2. I also faced this issue and tried editing react.gradle, deleted resources/drawable and all. But at last running the command gradlew assembleRelease worked for me.
I didn't run the react-native bundle command. gradlew assembleRelease is running the react-native bundle and building apk itself.

This works for me in react-native 0.63.2
            doLast {
                def flavorPathSegment = ""
                println targetName.toLowerCase();
                android.productFlavors.all { flavor ->
                    if (targetName.toLowerCase().contains(flavor.name.toLowerCase())) {
                        flavorPathSegment = flavor.name
                    }
                }
                def moveFunc = { resFolder ->
                    File originalDir = file("${buildDir}/generated/res/react/${flavorPathSegment}/release/${resFolder}");
                    if (originalDir.exists()) {
                        File destDir = file("${buildDir}/../src/main/res/${resFolder}");
                        ant.move(file: originalDir, tofile: destDir);
                    }
                }

                moveFunc.curry("drawable").call()
                moveFunc.curry("drawable-ldpi").call()
                moveFunc.curry("drawable-mdpi").call()
                moveFunc.curry("drawable-hdpi").call()
                moveFunc.curry("drawable-xhdpi").call()
                moveFunc.curry("drawable-xxhdpi").call()
                moveFunc.curry("drawable-xxxhdpi").call()
                moveFunc.curry("raw").call()
            }

Here the patch file react-native+0.63.2.patch
diff --git a/node_modules/react-native/react.gradle b/node_modules/react-native/react.gradle
index 6441d93..1eb4645 100644
--- a/node_modules/react-native/react.gradle
+++ b/node_modules/react-native/react.gradle
@@ -147,6 +147,33 @@ afterEvaluate {
                 jsSourceMapsDir.mkdirs()
             }

+            doLast {
+                def flavorPathSegment = ""
+                println targetName.toLowerCase();
+                android.productFlavors.all { flavor ->
+                    if (targetName.toLowerCase().contains(flavor.name.toLowerCase())) {
+                        flavorPathSegment = flavor.name
+                    }
+                }
+                def moveFunc = { resFolder ->
+                    File originalDir = file("${buildDir}/generated/res/react/${flavorPathSegment}/release/${resFolder}");
+                    if (originalDir.exists()) {
+                        File destDir = file("${buildDir}/../src/main/res/${resFolder}");
+                        ant.move(file: originalDir, tofile: destDir);
+                    }
+                }
+
+                moveFunc.curry("drawable").call()
+                moveFunc.curry("drawable-ldpi").call()
+                moveFunc.curry("drawable-mdpi").call()
+                moveFunc.curry("drawable-hdpi").call()
+                moveFunc.curry("drawable-xhdpi").call()
+                moveFunc.curry("drawable-xxhdpi").call()
+                moveFunc.curry("drawable-xxxhdpi").call()
+                moveFunc.curry("raw").call()
+            }
+
+
             // Set up inputs and outputs so gradle can cache the result
             inputs.files fileTree(dir: reactRoot, excludes: inputExcludes)
             outputs.dir(jsBundleDir)
diff --git a/node_modules/react-native/scripts/.packager.env b/node_modules/react-native/scripts/.packager.env
new file mode 100644
index 0000000..21a13cf
--- /dev/null
+++ b/node_modules/react-native/scripts/.packager.env
@@ -0,0 +1 @@
+export RCT_METRO_PORT=8081
\ No newline at end of file

thank you

Mike Hardy https://github.com/facebook/react-native/issues/22234#issuecomment-504721069 :pray: Thanks :+1:

Okay, the related PR here is going to have a "revert PR" - it causes a regression, and the underlying issue that caused this problem was bad documentation really.
Here's the thing: you should never copy things into the src directory during a build really. You need to copy things into intermediates and generated etc. If you have already copied things into src (from previous builds using this patch, or from a react-native bundle command): you need to clear those out so your src/main/res directory is clean - only real assets from your project
Now, to build an APK with an offline bundle - even in dev so you can run it on API < 17 you should do things differently than everyone on the web recommends (or you'll have this problem).
What you want is this in your android/app/build.gradle:
project.ext.react = [

        // This is what most people will need
        bundleInDebug: project.hasProperty("bundleInDebug") ? project.getProperty("bundleInDebug") : false,

        // If you use build variants it has to be like this - put your own names in there
        bundleInDevDebug: project.hasProperty("bundleInDevDebug") ? project.getProperty("bundleInDevDebug") : false,
        bundleInQaDebug: project.hasProperty("bundleInQaDebug") ? project.getProperty("bundleInQaDebug") : false,
        bundleInStagingDebug: project.hasProperty("bundleInStagingDebug") ? project.getProperty("bundleInStagingDebug") : false,
        bundleInProdDebug: project.hasProperty("bundleInProdDebug") ? project.getProperty("bundleInProdDebug") : false
]

Then you call react-native something like this - sending a gradle project property through via an environment variable:
ORG_GRADLE_PROJECT_bundleInDebug=true npx react-native run-android
(or for variants something like this ORG_GRADLE_PROJECT_bundleInDevDebug=true npx react-native run-android --variant devDebug)

My solution:
Delete all files in /your_project/android/app/src/main/raw/res.
It's work for me!

Thanks, Bro It works for me as well.

Change your wrong .png or .jpg file. It is solved... :innocent:

Why solving this, is still using workaround? why there is no fixing approach? I agree with what @safaiyeh says, editing node_modules everytime after npm install is not ideal, because your change in node_modules are not stored in git

I solved the problem by adding code here "node_modules/react-native/react.gradle"  in react-native 0.63.4

        doLast {
            def moveFolderFunc = { folderName ->
                File originalDir = file("$buildDir/generated/res/react/release/${folderName}");
                if (originalDir.exists()) {
                    File destDir = file("$buildDir/../src/main/res/${folderName}");
                    ant.move(file: originalDir, tofile: destDir);
                }
            }

            moveFolderFunc.curry("drawable-ldpi").call()
            moveFolderFunc.curry("drawable-mdpi").call()
            moveFolderFunc.curry("drawable-hdpi").call()
            moveFolderFunc.curry("drawable-xhdpi").call()
            moveFolderFunc.curry("drawable-xxhdpi").call()
            moveFolderFunc.curry("drawable-xxxhdpi").call()
            moveFolderFunc.curry("raw").call()
        }

Renamed the image from assets folder that is duplicate and then goto android/app/src/main/res/drawable-mdpi/
and delete image that were duplicate solved my problem!!

@ZeroCool00 wont that affect the images in Android?

This is working for me. Thanks

I initially met this problem like 5 years ago. I cannot believe today with RN 0.70.0 the problem still exists...

Remove the files you might have on:
android/app/src/main/res/drawable-mdpi/ android/app/src/main/res/drawable-xhdpi/ android/app/src/main/res/drawable-xxhdpi/ Run Build again, This fixed the issue for me.

Additionally removing raw folder fixed issue for me, Remove these and build again:
android/app/src/main/res/drawable-mdpi/
android/app/src/main/res/drawable-xhdpi/
android/app/src/main/res/drawable-xxhdpi/
android/app/src/main/res/raw/
Thanks

Try this :
Delete build inside android/app folder
Delete build inside android folder
run rm -rf $HOME/.gradle/caches/
Open build.gradle --> android/app/build.gradle
comment this line
//apply from: "../../node_modules/react-native/react.gradle"
Delete index.android.bundle file from assets folder and re-create using react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
run react-native run-android Or run react-native run-android --variant=release

doLast {
def moveFunc = { resSuffix ->
File originalDir = file("$buildDir/generated/res/react/release/drawable-${resSuffix}");
if (originalDir.exists()) {
File destDir = file("$buildDir/../src/main/res/drawable-${resSuffix}");
ant.move(file: originalDir, tofile: destDir);
}
}
moveFunc.curry("ldpi").call()
moveFunc.curry("mdpi").call()
moveFunc.curry("hdpi").call()
moveFunc.curry("xhdpi").call()
moveFunc.curry("xxhdpi").call()
moveFunc.curry("xxxhdpi").call()
}

I don't know how, I'don't know why but I've been searching for answers for 3 days and this solution works! thanks. Maybe you can explain what this code do to our project

I'm closing this issue as it's a 2018 issue and essentially unactionable from us.
The original issue is from React Native 0.57.x
If you're still having this failures on the latest version of the framework, please open a new issue.

The problem for my setup was this line in app/build.gradle leftover from older react-native versions:
apply from: "../../node_modules/react-native/react.gradle"

removed it and build works now

Thank you @andreiciceu. This worked for me too.

Sorry for my english.
This works for me.
Add new scripts in package.json

Generate the new bundle with generate:bundle
Clean up resources in drawable with clean:drawable
To generate an apk in release mode run  yarn android:release

{
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "clean:drawable": "rm -rf ./android/app/src/main/res/drawable-* && rm -rf ./android/app/src/main/res/raw",
    "generate:bundle": "npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && yarn clean:drawable",
    "android:release": "yarn generate:bundle && npx react-native run-android --variant=release"
  }
}

I hope this email finds you well. I wanted to share an informative blog post with you that I recently came across. Here i provide proper solution. In above example i check. Initially worked but when build upload that's time create issue.
https://medium.com/@yourerrorbro/handling-duplicate-resource-issue-in-android-released-builds-in-react-native-f63c67176bce

I remove it, but it still exist...I upgrade my react-native to "0.72.3", and it have not the file, and command. but it still exist the problem, and no idea to fix it.

I remove it, but it still exist...I upgrade my react-native to "0.72.3", and it have not the file, and command. but it still exist the problem, and no idea to fix it.

use @jcmunoz200 solution, then after you want to release it to playstore, do: cd android && ./gradlew bundleRelease

The problem for my setup was this line in app/build.gradle leftover from older react-native versions:
apply from: "../../node_modules/react-native/react.gradle"

removed it and build works now

Thank you, this is working for me.

work. so i downgrade my react-native version.

@SteveLai524 i am also facing same issue could you please tell me to which version you downgraded?

I don't have react.gradle file in RN v0.72.6, what do I have to do for this?

Same problem for me. Not able find solution for this. I am using RN v0.72.7

Sorry for my english.
This works for me.
Add new scripts in package.json

Generate the new bundle with generate:bundle
Clean up resources in drawable with clean:drawable
To generate an apk in release mode run  yarn android:release

{
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint . --ext .js,.jsx,.ts,.tsx",
    "clean:drawable": "rm -rf ./android/app/src/main/res/drawable-* && rm -rf ./android/app/src/main/res/raw",
    "generate:bundle": "npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res && yarn clean:drawable",
    "android:release": "yarn generate:bundle && npx react-native run-android --variant=release"
  }
}

It worked fine in my case

The problem for my setup was this line in app/build.gradle leftover from older react-native versions:
apply from: "../../node_modules/react-native/react.gradle"

removed it and build works now

Which RN version did you have?
I have 0.68 and this doesn't work

I initially met this problem like 4 years ago. I can hardly believe that today with RN 0.70.0 the problem still exists...

After upgrading an old react-native project to v0.71.0 the problem is still valid (6 years!!!). None of the fixes earlier in use seem to work (doLast, clean res, etc.) Anyone else having this issue and found a solution already?

I don't have react.gradle file in RN v0.72.6, what do I have to do for this?

@yogendrajs && @sharjeelhaider did you get solution for that scenario?


.NET November 2022 Update - .NET 6.0.11 and .NET Core 3.1.31

.NET November 2022 Update
Release Notes

6.0.11
3.1.31

Status

Asset Type
6.0.11
3.1.31
Notes

Installers/Binaries
✅
✅

Container Images(Linux)
✅
✅

Container Images(Windows)
✅
✅

Winget Packages
✅
✅

Snaps
✅
✅

Linux Packages (Microsoft distribution)

The list below refers to the Microsoft-provisioned feeds (packages.microsoft.com) and does not in any way represent direct availability in distros (eg RHEL, Fedora).

     Centos 7
✅
✅

     Debian 10
✅
✅

     Debian 11
✅
✅

     Fedora 35
✅
✅

     Fedora 36
✅
✅

     OpenSUSE 15
✅
✅

     Ubuntu 18.04
✅
✅

     Ubuntu 20.04
✅
✅

     Ubuntu 22.04
✅

Issues
Please report any issues you find either by responding to this issue, creating a new issue or creating a new issue in one of the following repos:

ASP.NET Core: dotnet/aspnetcore
Entity Framework Core: dotnet/efcore
.NET CLI/SDK dotnet/sdk
.NET runtime dotnet/runtime
Winforms: dotnet/winforms
WPF: dotnet/wpf
NuGet: nuget/home
Containers: dotnet/dotnet-docker
Winget: microsoft/winget-pkgs

Known Issues

According to the download page of the .NET 6 SDK, the v6.0.403 SDK is only compatible with Visual Stuido v17.3:

Using Visual Studio? This release is only compatible with Visual Studio 2022 (v17.3). Using a different version? See .NET SDKs for Visual Studio.

Why can't we use the latest version of Visual Studio 2022 (v17.4.2) with the latest version of the .NET 6 SDK (v6.0.403)?
Context: Our dependency upgrade bot upgraded the global.json file of a directory to v6.0.403 in one of our repositories and I updated Visual Studio to v17.4.2 on my machine. Now I always have to downgrade the .NET 6 SDK while developing locally...

Closing in favor of https://github.com/dotnet/core/issues/8037

@skyfrk do you mind creating a separate issue for this? I can then follow-up with some folks to see if maybe the language on the site is wrong.

Where should I open the issue? In this repo? @mairaw

Yes, please @skyfrk


datalog html: Document, fix, update, and create new test data

As a continuation for the changes implemented in PR https://github.com/lancaster-university/codal-microbit-v2/pull/196, this one updates the existing test files to contain more realistic raw data.
I believe the content of the sample-*.txt files might have been extracted from a browser save of the MY_DATA.HTM file, rather than from the straight raw data from the micro:bit. This is mostly indicated by the "empty space" being marked as 0xEFBFBD instead of 0xFF. In some cases, like the original sample-trailer.txt I could not manually fix the data, so had to create it from scratch by creating a MakeCode programme and extracting the raw data.
This is also useful because since the addition of the nRF52 Interface compatibility to CODAL some of the memory mapping has changed slightly.
I've also created additional test files and added descriptions to all of them in the README.

@microbit-matt-hillsdon Would you be able to review the PR? No need to look into the binary data, but it would be good to have a second pair of eyes to see if the README additions make sense.

I'll squash the last three commits for a cleaner git history, as it'd be good to keep the first two separated.


Region is not that clear

In the form, users select Europe-West. But we select the CFs from the UK. This is not clear in the table, but I think it should

We might simply add in brackets the location, as we have for AWS.


Document new DOCKER-USER iptables chain

Proposed changes
Adds just a bit about iptables but not a full treatment for now.
Fixes #3518
Unreleased project version (optional)
Docker 17.06

I took a stab at re-wording. Thanks for the clarification.


Review

Thanks for the module! :smiley:  I have some change suggestions.
There are no functional changes.

@SalekurPolas did you noticed this PR? :slightly_smiling_face:

Okay, I just reentered the Manual Installation section. Is that okay? :slightly_smiling_face:

Thanks for your work :)


PLAN-80 Username/password login

Login:

Can log in with a username and password
Can ask for a password reset email
Can click the link in the password reset email and reset your password
Error messaging for when those things don't work
Terms of Service link
Privacy Policy link

Development environment improvements:

livereload
mailcatcher
storybook

[ ] format everything


Open URL that is present in the documentation window

Sometimes there are links to outside sources in the documentation window. It would be nice if I could bind a key to open these links in my browser. An alternative could be to be able to jump into the documentation window, find the link "by hand" and press gx on it.

This will be awesome, I am playing around on creating a snippet for Ruby on Rails, and was facing a problem with the documentation link being too long and it broke the link. It would be also nice if we can set the conceal level for the documentation window.


Architecture Proposal (DO NOT MERGE)

Model for documentation architecture. Updated sidebar navigation and header links.
NOTE: Links sidebar links not working (collecting feedback)

@joenyzio can we close this now?

Closing to clean PRs.


Custom Lambda layer Keras outputs predictions. I get 'An operation has None for gradient' error

Please make sure that the boxes below are checked before you submit your issue.
If your issue is an implementation question, please ask your question on StackOverflow or on the Keras Slack channel instead of opening a GitHub issue.
Thank you!

[x] Check that you are up-to-date with the master branch of Keras. You can update with:
pip install git+git://github.com/keras-team/keras.git --upgrade --no-deps

[x] Check that your version of TensorFlow is up-to-date. The installation instructions can be found here.

[x] Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).

I have a Lambda layer that takes input from previous layer and makes some preprocessing. Output of the Lambda layer is a prediction, and keras.losses.mean_squared_error is used.
#model
inputs = Input(shape=(len_train_data_columns,))
dense1 = Dense(777, activation='relu')(inputs)
dropout1 = Dropout(0.4)(dense1)
softmax = Dense(3, activation='softmax')(dropout1)
predictions = Lambda(custom_layer,
            output_shape= custom_layer_output_shape,
            arguments= {'experiment_config': experiment_config},
               )(softmax)

I get ValueError: An operation has None for gradient. Please make sure that all of your ops have a gradient defined (i.e. are differentiable). Common ops without gradient: K.argmax, K.round, K.eval.

I checked the custom layer output shape and X_train shape, they are same shape.
Why is that? I use Keras loss...
Here is StackExchange post: https://datascience.stackexchange.com/questions/48134/custom-lambda-layer-keras-outputs-predictions-i-get-an-operation-has-none-fo

I have a Lambda layer that takes input from previous layer and makes some preprocessing. Output of the Lambda layer is a prediction, and keras.losses.mean_squared_error is used.
#model
inputs = Input(shape=(len_train_data_columns,))
dense1 = Dense(777, activation='relu')(inputs)
dropout1 = Dropout(0.4)(dense1)
softmax = Dense(3, activation='softmax')(dropout1)
predictions = Lambda(custom_layer,
            output_shape= custom_layer_output_shape,
            arguments= {'experiment_config': experiment_config},
               )(softmax)

I get ValueError: An operation has None for gradient. Please make sure that all of your ops have a gradient defined (i.e. are differentiable). Common ops without gradient: K.argmax, K.round, K.eval.
I checked the custom layer output shape and X_train shape, they are same shape.
Why is that? I use Keras loss...
Here is StackExchange post: https://datascience.stackexchange.com/questions/48134/custom-lambda-layer-keras-outputs-predictions-i-get-an-operation-has-none-fo

Any updates?


Passkey plugin - Remove redundant calls to passkey-server during message signing

Suggested solution to #152

Add new property to WebAuthnKey type - authenticatorId, which will be used to form allowedCredentials object for signing options while signing a message;
Modify toWebAuthnKey function to include authenticatorId in the response;
Remove passkey-server calls from toPasskeyValidator's signMessageUsingWebAuthn function;
Add couple of helper functions to utils to be able to derive all of the required data for signing without reaching out to passkey-server.

@hjornigur I think it does make sense, and the code looks good to me. Thanks for the contribution. I'll merge it after testing it.

@adnpark Cool, glad to hear it!
I've noticed that the latest  'main' commit introduced some conflict with the PR, should I resolve the conflict myself before the merge?

@hjornigur Thanks for resolving the conflict!
I've pushed a new commit which removes passkeyServerUrl (as you said, now we don't need it in passkeyValidator. Also fixed some build error regarding ArrayBuffer. You can reproduce the error by running bun run build inside of plugins/passkey directory. (Don't forget to run bun install in the root dir)
And I've also tested out the new version and it works like a charm. So I think if you're ok with the current code, let's merge it. Whenever it merged, I'll publish new version for it.

@adnpark Oh, that's interesting, glad the fixed version worked out fine!
I can't reproduce the error in the forked repo (I have some issues regarding resolving peer dependencies in plugins subfolder), but in my project I just don't get any errors regarding passing Uint8Array instance as ArrayBuffer to the base64FromArrayBuffer function, maybe because I have a different node or typescript version where they may have matching interfaces 🤔
Regarding the final code, what do you think of changing the base64FromArrayBuffer() to the base64FromUint8Array(), and just passing the hexStringToUint8Array(formattedMessage) to it?
Since the helper is just used for this single conversion, this change may simplify the flow a little bit

@hjornigur It makes sense.
I've simplified the encoding process, can you check if it does make sense? And also, I've removed userIds since they were only used for calling sign- apis.
If you're ok with the changes, let me merge it into the main branch now.

@adnpark Yes, now looks good to me!


DeployToXXXX_QA fails with error: Environment URL '' is not a valid http(s) URL, so it will not be shown as a link in the workflow graph.

Hi
DeployToXXXX_QA fails with error:
_Unexpected error when running action. Error Message: Authentication failed. Authentication failed, StackTrace: at , /home/runner/work/_actions/microsoft/AL-Go-Actions/v4.0/Deploy/Deploy.ps1: line 169 <- at , /home/runner/work/temp/cb9764fd-e77f-4702-a69c-2d27a86b0728.ps1: line 4 <- at , : line 1
Process completed with exit code 1.
Environment URL '' is not a valid http(s) URL, so it will not be shown as a link in the workflow graph.
DeployToXXXX_QA fails both from CICD and publish to environment.
Publish to environment work last 28 nov 2023 08:10 GMT
and have not worked since 20 nov 2023 17:30 GMT

I have tried with new DeployTo, which I am using now and the old way.
I have tried borh windows and ubuntu, which iI am using now.

Please help me to get DeployToXXXX_QA to work again.
/J

Looking at the error above - it says that the refresh token is not valid - it might have expired - then you need to recreate the authcontext secret with a new value.
I think your settings looks fine, here are the recommendations:
If the name of the environment (in GitHJub) is XXX_QA and the name of the environment in BC admin center is BC_QA - then this setting should work:
"DeployToXXX_QA": {
  "EnvironmentName": "BC_QA",
  "SyncMode": "ForceSync"
}

We do not recommend setting properties, which you don't change.
The recommended authcontext secret should be created as an environment secret and be called AUTHCONTEXT. If you do not use environment secrets, you can still call it AUTHCONTEXT, then it will be used for all environments - or you can call it XXX_QA_AUTHCONTEXT.

Hi, now it works.
Thank you.
I do not know why, because had allready tried to update authcontext before I created this issue.
XXX_QA is set both as github and BC environment.
Do you mean that I should not use settings if they do not change default values.
So I should not use settings
"DeployToXXX_QA": {
"EnvironmentType": "SaaS",
"EnvironmentName": "XXX_QA",
"Branches": [
"main"
],
"Projects": "",
"SyncMode": "ForceSync",
"ContinuousDeployment": true,
"runs-on": "ubuntu-latest"
},
"DeployToXXX_UAT": {
"EnvironmentType": "SaaS",
"EnvironmentName": "XXX_UAT",
"Branches": [
"main"
],
"Projects": "",
"SyncMode": "ForceSync",
"ContinuousDeployment": false,
"runs-on": "ubuntu-latest"
},
but use only these settings:
"DeployToXXX_QA": {
"SyncMode": "ForceSync",
"runs-on": "ubuntu-latest"
},
"DeployToXXX_UAT": {
"SyncMode": "ForceSync",
"ContinuousDeployment": false,
"runs-on": "ubuntu-latest"
},
I tried both setting now when Publish worked and both settings worked.

at https://aka.ms/algosettings#deployto you can see the defaults for these things and for this:
EnvironmentType is SaaS by default - no need to set that
EnvironmentName is the same as the github environment name - no need to set that
branches is main by default.
projects is * by default
runs-on defaults to whatever runs-on is globally - no need to set that.
The rest is special - you should set that.


Help wanted: Improve documentation

The ModelFusion documentation could be expanded to include more details and make it easier to understand. If you have suggestions or ideas, please contribute!

@lgrammel I can help out.

@erickNjuki great - there is some existing structure already. The easiest way to get started could be by adding something more specific, e.g. creating a tutorial on something that hasn't been covered yet, or expanding an existing page in the guide. Have you e.g. used ModelFusion for something that you think could be interesting?


Fix Node.extra having incomplete block_device_mapping on EC2

Fix Node.extra having incomplete block_device_mapping on EC2
Description
Fix node's Block Device Mapping was parsed from incorrect mapping.
EbsInstanceBlockDevice is different from  EbsBlockDevice.
Status

done, ready for review

Checklist (tick everything that applies)

[x] Code linting (required, can be done after the PR checks)
[ ] Documentation
[x] Tests
[ ] ICLA (required for bigger changes)

Coverage increased (+0.005%) to 88.233% when pulling 8b9ab72c72afe8b7ee0b4e6dec03438977a79371 on Scalr:for-upstream/ec2-instance-bdm into 98c4fe0a085717e1a5353edf8cb9c3d3f699ed5d on apache:trunk.

:+1: thanks @uty


Can place items on wall areas in houses that shouldnt be possible

you can place items here on your walls where you shouldnt be able to , tried to read the terrain and bounce the item with a script fix, but i wasnt able to get the static info from the multi it seems.

I think this have been like this for many time.
To reach the static from multi u need to do a for among all statics until u get the one with the desired coords.
Does it happens on walls that are not multis?

I don't believe this is normal behavior that exists in UO, or that it has existed in the past with sphere, that you can drop items onto a tile that has a wall on it.
you can't drop item's on walls in the regular game mechanics.

closed because duplicate


Add .sdkmanrc with 8.0.345-tem

.sdkmanrc is used by sdkman to automatically switch to the version
declared in the file.

Java 8 for Eclupse Temurin is not available for macos M1 but I think it will be only a few contributors who will not benefit for it.


Update Microsoft.Unity.Analyzers package to 1.13

Update from 1.7.0 to 1.13.0
https://github.com/microsoft/Microsoft.Unity.Analyzers/compare/1.7.0...1.13.0
UNT0018 onwards are new:

ID
Title
Category

UNT0018
System.Reflection features in performance critical messages
Performance

UNT0019
Unnecessary indirection call for GameObject.gameObject
Performance

UNT0020
MenuItem attribute used on non-static method
Correctness

UNT0021
Unity message should be protected [opt-in]
Correctness

UNT0022
Inefficient method to set position and rotation
Performance

UNT0023
Coalescing assignment on Unity objects
Correctness

UNT0024
Give priority to scalar calculations over vector calculations
Performance

UNT0025
Input.GetKey overloads with KeyCode argument
Correctness

UNT0026
GetComponent always allocates
Performance

bump


When using HTTP GET to access the WHIP API, the error codes are not accurate.

Describe the bug
Normally, users should access the WHIP API using HTTP POST. But sometimes, users might habitually paste the WHIP API into the browser to access it. In this case, the error logs from SRS are not very clear, and there isn't a clear error response either.
Version
SRS 5.0 and 6.0
To Reproduce
Steps to reproduce the behavior:

Run SRS by ./objs/srs -c conf/console.conf
Use curl to request WHIP API: curl -v 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream'
The response is not clear:

curl -v 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream'
*   Trying <IP_ADDRESS>:1985...
* Connected to localhost (<IP_ADDRESS>) port 1985 (#0)
> GET /rtc/v1/whip/?app=live&stream=livestream HTTP/1.1
> Host: localhost:1985
> User-Agent: curl/8.1.2
> Accept: */*
>
* Empty reply from server
* Closing connection 0
curl: (52) Empty reply from server

SRS error is not clear:

[2023-10-16 08:56:29.205][INFO][50045][1np2j16n] HTTP #0 <IP_ADDRESS>:58926 GET http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream, content-length=-1
[2023-10-16 08:56:29.206][INFO][50045][1np2j16n] RTC whip publish /live/livestream, clientip=<IP_ADDRESS>, app=live, stream=livestream, offer=0B, eip=, codec=, srtp=, dtls=, ufrag=, pwd=, param=app=live&stream=livestream
[2023-10-16 08:56:29.206][INFO][50045][1np2j16n] TCP: before dispose resource(HttpConn)(0x607000003f20), conns=1, zombies=0, ign=0, inz=0, ind=0
[2023-10-16 08:56:29.207][ERROR][50045][1np2j16n][35] serve error code=5018(RtcSdpNegotiate)(RTC do SDP negotiate failed) : process request=0 : cors serve : serve http : serve : serve : remote sdp check failed : now only support BUNDLE, group policy=
thread [50045][1np2j16n]: process_requests() [./src/app/srs_app_http_conn.cpp:209][errno=35]
thread [50045][1np2j16n]: process_request() [./src/app/srs_app_http_conn.cpp:236][errno=35]
thread [50045][1np2j16n]: serve_http() [./src/protocol/srs_protocol_http_stack.cpp:768][errno=35]
thread [50045][1np2j16n]: serve_http() [./src/app/srs_app_rtc_api.cpp:628][errno=35]
thread [50045][1np2j16n]: do_serve_http() [./src/app/srs_app_rtc_api.cpp:739][errno=35]
thread [50045][1np2j16n]: serve_http() [./src/app/srs_app_rtc_api.cpp:470][errno=35]
thread [50045][1np2j16n]: check_remote_sdp() [./src/app/srs_app_rtc_api.cpp:529][errno=35](Resource temporarily unavailable)

Expected behavior
SRS should use more specific error codes, instead of the current now only support BUNDLE.
SRS should return error codes and messages in the HTTP Response.
Additional context
Note: Previously, no error response was returned, primarily for simplicity. Also, when returning a response, sensitive information needs to be avoided. There were many factors to consider, so detailed error messages were not returned.
TRANS_BY_GPT4

Fixed.


chore: remove unused social styles

#447  👈
main

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @davidlj95 and the rest of your teammates on  Graphite


[webpack5]  webpack_modules[moduleId] is not a function

webpack  The version used when packaging : v5.44.0
webpack Version at the time of project use： v4.46.0

Problem Description：
When webpack5 uses the packaging library, it uses extenals to exclude some node_modules, and the packaged library code includes require syntax. When used in the webpack4 project, the package introduced by require will use webpack_modules to find it, causing an error [index.js:56 Uncaught TypeError: webpack_modules[moduleId] is not a function]
But I use webpack5 to use the library, it seems there is no problem
like issues： https://github.com/webpack/webpack/issues/11277

same thing for me, but only when I build a library in the development mode

same thing for me, but only when I build a library in the development mode

I used webpack5's production mode to package a.js. But using a.js in the development mode of webpack4 will cause the above problems. But using webpack4 to package a.js is no problem. How did you solve it

@hello-lun I did not. Let's see what the maintainers say. Should this be supported?

@hello-lun I did not, ended up using Rollup to bundle my library.
Let's see what the maintainers say. Should this be supported?

What a coincidence, I ended up packing it with rollup. But webpack4 can also achieve the goal


initializer needs to be run after sprockets.environment

https://github.com/railsjedi/ruby-stylus/commit/4a8d1d4136cc9fae9cc8a56fc9d234c1428f0f20
otherwise app.assets will be nil

Not quite true. If you add "stylus" after "rails" but before the assets block, it will still blow up. There should be at least be a "gotcha" in the README for this.


fix: Standalone download and installation for Apple m1

The purpose of this PR is to enable the download and installation of the Standalone binaries for Apple m1 chips (os: darwin, arch: arm64).
Binaries for Mac OS seem to be already compatible and only a check made via the package.json prevents the download and installation.
I also added a step for downloading and checking the checksum, as the process was failing because the checksum file was not downloaded automatically

@obiSerra do you know, is this message somehow could be fixed by your PR?
I have the following issue with docker on m1
#9 26.86 error<EMAIL_ADDRESS>The CPU architecture "arm64" is incompatible with this module.

@konalegi The error message is correct, because we don't have binaries for M1 yet. See #264 for details and a workaround.
I'm going to close this for now, because we can't merge it before we support M1.

@TimothyJones Those workarounds don't work for me, because I'm running inside docker which is under arm64. I guess I have to wait for m1 support.

@konalegi: We changed direction on this, and<EMAIL_ADDRESS>/<EMAIL_ADDRESS>have this workaround included.


Zen mode: title broken in this case

Steps to Reproduce:

go full screen
enable zen mode
leave full screen

=> for me the custom title is not showing anymore

Can not repro 😭

Ahaa I can not repro in out of source since there it is not possible to have the custom title bar for some reasone you menitoned in the standup

Yeah, custom title disabled running out of sources due to some issues with dev tools.

By the way would you in this scenario expect to get out of zen mode or stay in zen mode?

@isidorn I agree with you


Forgot password

Solves the issue of visual presentation, will require live testing on production to verify email works for password recovery.
Linked to issue 15.


Typo in article?

The left-hand colored bar designates 'teh' state of each item
Is that a typo? :p

Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

ID: e841ba7c-fa53-e50c-24d4-aef0d5d865e4
Version Independent ID: a5abe379-3258-c90c-5599-dce78141bb44
Content: Dependency Tracker Timeline - Azure DevOps
Content Source: extensions/dependency-tracker/Timeline.md
Product: devops
GitHub Login: @cherylsingh
Microsoft Alias: chesing

I've addressed this issue in the linked PR. Thanks for your feedback!
#please-close


[WIP] Simplified Vercel template drastically

With this change, the Vercel template generated by create-remix becomes much simpler.

https://vuuzletvph.com/heads-up-vuco-bounty-programs-are-coming-your-way/


[Feature Request] Wiki additional functionality

Allow the wiki to link to items in your bank, and allow the wiki to link on the achievement diaries

#7854 #7859


'module' object has no attribute 'compile'

I'm running Python 2.7.10 on Ubuntu 14.04 via Anaconda.
Running the example code I come across this.
$ pip freeze | grep libsass
libsass==0.10.1
$ python
Python 2.7.10 |Continuum Analytics, Inc.| (default, May 28 2015, 17:02:03)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import sass
>>> sass.__version__
'2.2+libsass1.0.1'
>>> print sass.compile(string='a { b { color: blue; } }')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'compile'
>>> print sass.compile_string('a { b { color: blue; } }')
a b {
  color: blue; }
>>> dir(sass)
['CompileError', 'SASS_STYLE_COMPACT', 'SASS_STYLE_COMPRESSED', 'SASS_STYLE_EXPANDED', 'SASS_STYLE_NESTED', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__test__', '__version__', 'compile_file', 'compile_string']

I find the __version__ value quite strange.
This is even more bizarre because the sass.py has the function def compile(**kwargs) in it.
$ cat ~/.anaconda/envs/systema/lib/python2.7/site-packages/sass.py | grep "def compile("
def compile(**kwargs):

This is also quite strange
>>> help(sass)
<snip>
FILE
    /home/adamgriffiths/.anaconda/envs/systema/lib/python2.7/site-packages/sass.so
<snip>

I would have expected that to be sass.py, .pyc, or .pyo

This doesn't look like our module at all.  Can you reproduce in an empty environment?

I think you've accidentally also installed https://github.com/rsenk330/pylibsass/blob/master/setup.py (which is out of date, and provides the same module name as we do for our c bits)
Uninstalling both and reinstalling libsass should fix the problem

Thanks for the tip.
Turns out I had a library called sass shadowing libsass. I must've installed it a while ago.
$ pip freeze | grep sass
libsass==0.10.1
sass==2.3

Removing it fixed the problem.
Thanks again.


[Runtime Options] Rename reporters for consistency

Removed the "get" in the reporters for consistency

Current blockset

Proposed change

Also for the booleans

Old blockset

Proposed change for consistency (with comparison example)

Last one, just keep noticing stuff:

Old blockset

Proposed change (for consistency even within the extension itself))


Flat background

How can I set up just a flat background color without gradient?

Already tried
popup.hasShadow = NO;
popup.has3DStyle = NO;

In search of a solution I downloaded the source and founded this property:
popup.hasGradientBackground = NO;

Maybe it's time to update the README..