Duplicate Resources Error- React Native 0.60+

Shreyas Nisal
2 min readOct 17, 2019

--

I wrote an article on fixing the packaging error when building an apk with React Native. The error was regarding bundling issues and the presence of duplicates of some resources. However, the same procedure does not work for React Native 0.60+. So in case you have a duplicate resources error in React Native now, how do you go about fixing it?

First things first, you don’t need the bundling command before trying to build an apk from React Native now. However, in case you still have the “duplicate resources” error, the way to fix it is simple.

Go to android/app/src/main/res and delete all the directories starting with drawables. This is similar to what we did for earlier versions of React Native. However, this time, also delete the directory named raw, which contains .json files, including app.json. Now, you’re ready to build your apk. Before you do so, make sure none of your own assets (images, videos, etc) do not have the same name, since that would also yield a duplicate resources error. Having done that, head to the terminal and change your directory to /android . It is always a good idea to run ./gradlew clean (skip the “./” if you’re a windows user) before you move on to generating the apk. The command deletes the build directory, so that you have nothing left from your earlier builds, be it a release build or a debug one.

Finally, run the command ./gradlew assembleRelease (once again skip the “./” for windows users) from the /android directory to generate the apk. This might take a while, but it should generate an apk file in your build/outputs directory.

Hope this article helps and saves you hours more of searching on forums. If it helped, don’t forget to give a clap, and follow me for more such fixes and tricks!

P.S. There might be other ways to fix the duplicate resources error, such as adding code to the node_modules/react-native/react.gradle but I personally would not recommend such a thing since modifying existing code/native code is not such a great idea. Also, if the issue persists or you do not find the directories mentioned above at all, run the bundling command from my previous article on fixing the packaging error, which you can read here.

--

--

Shreyas Nisal
Shreyas Nisal

Written by Shreyas Nisal

Software Engineer at Twilio | Ex Research Assistant at MIT Media Lab, Exertion Games Lab | Ex Intern at Twilio, BitHyve, Mednet Labs

Responses (2)