How to resolve React Native : Error: Duplicate resources - Android Error? | Technical, Finance, Investment Questions

How to resolve React Native : Error: Duplicate resources - Android Error?

Namratha Reddy

7 months ago

I am trying to create release bundle from Android but when I create release bundle, I was getting Duplicate Resource error like below:


React Native : Error: Duplicate resources - Android 


Solution: 


I followed later below steps to resolve the issue: 


  1. First we have to clean build by gradle by using below commands: 
  2. cd android
  3. ./gradlew clean 
  4. Once clean is complete, go to node_modules folder and open react-native folder inside node_modules folder. 
  5. Open react.gradle file and add the below code after doFirst block inside react.gradle file and save the file.



doFirst {

        jsBundleDir.deleteDir()

        jsBundleDir.mkdirs()

        resourcesDir.deleteDir()

        resourcesDir.mkdirs()

        jsIntermediateSourceMapsDir.deleteDir()

        jsIntermediateSourceMapsDir.mkdirs()

        jsSourceMapsDir.deleteDir()

        jsSourceMapsDir.mkdirs()

}


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

}

Namratha Reddy

QA Engineer at Wipro Singapore

7 months ago

Featured Blogs
not found

Category: Investment

Author: Sushmita Pal

Posted : 24 hours ago

0( 0 Comments )
not found

Category: Investment

Author: Sushmita Pal

Posted : 3 days ago

60( 0 Comments )
not found

Category: Startup

Author: Anushka Trivedi

Posted : 4 days ago

50( 0 Comments )
not found

Category: Investment

Author: Anushka Trivedi

Posted : 4 days ago

32( 0 Comments )
not found

Category: Investment

Author: Anushka Trivedi

Posted : 4 days ago

64( 0 Comments )
not found

Category: Startup

Author: Anushka Trivedi

Posted : 9 days ago

142( 0 Comments )
not found

Category: Startup

Author: Anushka Trivedi

Posted : 12 days ago

122( 0 Comments )
not found

Category: Technology

Author: Sweety Singh

Posted : 12 days ago

173( 0 Comments )
not found

Category: Stocks

Author: Sweety Singh

Posted : 14 days ago

69( 0 Comments )
not found

Category: Technology

Author: Sweety Singh

Posted : 14 days ago

53( 0 Comments )
Featured Questions
not found

Category: NextJs

Author: Pratiksha Sharma

Posted : 5 months ago

209( 0 Comments )
not found

Category: Technology

Author: John Milliate

Posted : 5 months ago

127( 0 Comments )
not found

Category: Technology

Author: John Milliate

Posted : 5 months ago

121( 0 Comments )
not found

Category: Technology

Author: Anwesha Chourasia

Posted : 6 months ago

159( 0 Comments )
not found

Category: Technology

Author: Priya Singh

Posted : 7 months ago

126( 0 Comments )
not found

Category: Technology

Author: Priya Singh

Posted : 7 months ago

166( 0 Comments )
not found

Category: Technology

Author: Shruthi Sinha

Posted : 7 months ago

135( 0 Comments )
not found

Category: Technology

Author: Anish Srivastava

Posted : 8 months ago

265( 1 Comments )

Category: Technology

Author: Mahak Chahal

Posted : 10 months ago

34( 1 Comments )