Home » React-native » Duplicate resources React Native Android

Duplicate resources React Native Android

Pro Level React-native

Hi Guys, In this article, we are learning about Duplicate resources React Native Android error. generally, we face this error while creating a signed apk or production build. To create React Native Android build we need to create index.android.bundle inside the asset folder. to create this bundle check this post. after creating this bundle you will be able to reproduce this error in Android studio. so basically bundle creation process creates duplicates of drawable files in the project. to solve this error we have to delete duplicate resources files then we have to add some code in node modules react-native Gradle file then create build again and the error will be fixed, so let’s solved it step by step.

You will see the following error in android studio.Duplicate resources React Native Android

So, do not panic after facing this error. try the following solution and you can able to fix this error

1. Try cleaning the Android project.

In the terminal project root folder, go to the android folder using cd android. Using the following comment to clean the android project.

./gradlew clean

2. Try deleting the drawable folder

After creating the bundle delete the drawable folder from Android Studio. You could find this in the path android/app/src/main/res/drawable

3. Add the following code in react.gradle

Add the following code below doFirst in path node_modules/react-native/react.gradle. save this file and we have to create build again. check this post for the command to create a build. also, you can now delete duplicate resources from the drawable folder then clean and build the project.

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);

I was getting the same duplicate resources React Native Android error while creating the signed APK and I solved this error using the same solution. try this solution and let me know if any other issues. and make sure you need to refresh the project & run the project again to reflect these changes.

Thank you.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *