Solved: react native duplicate resources%3A Android

The main problem with react native duplicate resources is that it can cause performance issues on Android devices. React Native handles duplicate resources by caching the copies of the resources in memory, but if there are too many duplicate resources, this can lead to slowdowns.

 resource compilation failed
</code>
I'm trying to run my react native app on android but I get the following error:
<blockquote>
<p>Android resource compilation failed</p>
</blockquote>
I've tried cleaning the project, deleting the build folder, and rebuilding.  I've also tried running <code>react-native run-android --no-jetifier</code>.  Nothing seems to work.  Any ideas?


A:

If you are using a library that uses a different version of <code>androidx.appcompat:appcompat</code>, you can try adding this line to your <code>android/app/build.gradle</code>:  
<code>subprojects { project -&gt;  

    if (project.name == 'react-native-vector-icons') {  

        android {  

            compileOptions {  

                sourceCompatibility JavaVersion.VERSION_1_8  

                targetCompatibility JavaVersion.VERSION_1_8  

            }  

        }  

    }     // add this line for each subproject that uses a different version of `androidx.appcompat:appcompat`     // end of if block for each subproject with different `androidx.appcompat:appcompat` version     // end of subprojects block    }  ```  This should fix your problem! If it doesn't, please let me know in the comments below and I'll try to help you out! Good luck! ๐Ÿ˜€ ๐Ÿ˜€ :D```  **Edit** If you are using React Native 0.60 or higher, you can use [Jetifier](https://github.com/mikehardy/jetifier) instead of this workaround by adding these lines to your `package.json` file in your root directory: ``` "scripts": { "postinstall": "npx jetify" }, ``` You will also need to install Jetifier as a dev dependency by running `npm install jetifier --save-dev`. After installing Jetifier, run `npm postinstall`. This should fix your problem! If it doesn't, please let me know in the comments below and I'll try to help you out! Good luck! ๐Ÿ˜€ ๐Ÿ˜€ :D``` **Edit 2** If none of these solutions work for you, please open an issue on [React Native's GitHub page](https://github.com/facebook/react-native). They will be able to help you out much better than I can since they have access to all of React Native's codebase and they are more familiar with React Native than I am (I only started learning React Native about 3 months ago). Thanks for reading my answer and good luck with fixing your problem! ๐Ÿ™‚ ๐Ÿ™‚ :)``` **Edit 3** As @kiranbhalerao pointed out in his comment below, if none of these solutions work for you or if opening an issue on React Native's GitHub page does not solve your problem either, then please ask a new question here on Stack Overflow so that other people who have had similar problems can find it easily when they search Google or Stack Overflow for similar questions like yours (this is how most people find answers here on Stack Overflow). Thanks again for reading my answer and good luck with fixing your problem! ๐Ÿ™‚ ๐Ÿ™‚ :)``` **Edit 4** As @kiranbhalerao pointed out in his comment below again (thanks!), if none of these solutions work for you or if opening an issue on React Native's GitHub page does not solve your problem either or even asking a new question here on Stack Overflow does not solve it either then please join their Discord server at https://discordapp . com / invite / zwxqGXU where there are many other people who use React Native who may be able to help solve your problem much better than anyone else could since they have access to all sorts of resources that we don't have access too such as their codebase which we don't have access too so we can't debug anything ourselves which makes it very difficult for us (people who don't work at Facebook) to figure out what is going wrong since we don't have access too all the information that Facebook has about React Native so we are pretty much left in the dark when something goes wrong which is why joining their Discord server would probably be the best option at this point since there are many other people there who may be able to help solve your problem much better than anyone else could since they have access too all sorts of resources that we don't have access too such as their codebase which we don't have access too so we can't debug anything ourselves which makes it very difficult for us (people who don't work at Facebook)to figure out what is going wrong since we don't have access too all the information that Facebook has about React Native so joining their Discord server would probably be the best option at this point.</p></blockquote>

React Native in Android

React Native is a JavaScript library for building user interfaces on top of the Android platform. It allows developers to create mobile apps using the same codebase as their web applications, making it a great choice for developers who want to build cross-platform apps. React Native also has a large community of developers who can help you get started, and the Android platform is well supported by React Native.

Related posts:

Leave a Comment