react-native-vector-icons: [solved] Duplicate resources android build error with v9.1.0 - [fonts were in source tree *and* using module's build.gradle font copy]
- Review the documentation: https://github.com/oblador/react-native-vector-icons
 - Search for existing issues (including closed issues): https://github.com/oblador/react-native-vector-icons/issues
 
Environment
react-native 0.67.2, gradle 7.4, android gradle plugin 7.1.1, react-native-vector-icons 9.1.0 (hot off the presses!)
Description
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDevDebugAssets'.
> [fonts/Fontisto.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/Fontisto.ttf    [fonts/Fontisto.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/Fontisto.ttf: Error: Duplicate resources
  [fonts/Octicons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/Octicons.ttf    [fonts/Octicons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/Octicons.ttf: Error: Duplicate resources
  [fonts/Feather.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/Feather.ttf      [fonts/Feather.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/Feather.ttf: Error: Duplicate resources
  [fonts/Entypo.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/Entypo.ttf        [fonts/Entypo.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/Entypo.ttf: Error: Duplicate resources
  [fonts/FontAwesome5_Brands.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/FontAwesome5_Brands.ttf      [fonts/FontAwesome5_Brands.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/FontAwesome5_Brands.ttf: Error: Duplicate resources
  [fonts/MaterialCommunityIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/MaterialCommunityIcons.ttf        [fonts/MaterialCommunityIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/MaterialCommunityIcons.ttf: Error: Duplicate resources
  [fonts/AntDesign.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/AntDesign.ttf  [fonts/AntDesign.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/AntDesign.ttf: Error: Duplicate resources
  [fonts/Foundation.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/Foundation.ttf        [fonts/Foundation.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/Foundation.ttf: Error: Duplicate resources
  [fonts/Ionicons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/Ionicons.ttf    [fonts/Ionicons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/Ionicons.ttf: Error: Duplicate resources
  [fonts/FontAwesome5_Solid.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/FontAwesome5_Solid.ttf        [fonts/FontAwesome5_Solid.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/FontAwesome5_Solid.ttf: Error: Duplicate resources
  [fonts/FontAwesome5_Regular.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/FontAwesome5_Regular.ttf    [fonts/FontAwesome5_Regular.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/FontAwesome5_Regular.ttf: Error: Duplicate resources
  [fonts/FontAwesome.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/FontAwesome.ttf      [fonts/FontAwesome.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/FontAwesome.ttf: Error: Duplicate resources
  [fonts/Zocial.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/Zocial.ttf        [fonts/Zocial.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/Zocial.ttf: Error: Duplicate resources
  [fonts/EvilIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/EvilIcons.ttf  [fonts/EvilIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/EvilIcons.ttf: Error: Duplicate resources
  [fonts/SimpleLineIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/SimpleLineIcons.ttf      [fonts/SimpleLineIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/SimpleLineIcons.ttf: Error: Duplicate resources
  [fonts/MaterialIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/src/main/assets/fonts/MaterialIcons.ttf  [fonts/MaterialIcons.ttf] /Users/mike/work/EquityResidences/equityresidences/packages/public-app/android/app/build/intermediates/ReactNativeVectorIcons/fonts/MaterialIcons.ttf: Error: Duplicate resources
Reproducible Demo
I’m still investigating this but thought to log it quickly since rolling back to 9.0.0 does not cause a build faliure, while 9.1.0 does. I can confirm with 9.0.0 I actually do have vector icons showing up as well so by all appearances 9.0.0 is working
Likely cause #1401 but I haven’t looked into it thoroughly yet
I tried rm -fr android/build android/app/build and rebuilt, just to see if that had an effect. No effect. Only the revert to v9 is successful at the moment
I am not including specific fonts, the tail of my android/app/build.gradle is:
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
About this issue
- Original URL
 - State: closed
 - Created 2 years ago
 - Reactions: 8
 - Comments: 41 (16 by maintainers)
 
Commits related to this issue
- Fix duplicate fonts. See oblador/react-native-vector-icons#1416. — committed to coopcycle/coopcycle-app by alexsegura 2 years ago
 
Yeah, I’m pretty confident this is the case. You should pick one approach, either manually copying them to your fonts folder, or copying on build with gradle. To fix this error simply remove the duplicates in
packages/public-app/android/app/src/main/assets/fonts, they are most likely out of date anyways.Same problem in v9.1.0, removing them will work again:
android/app/src/main/fonts/AntDesign.ttfandroid/app/src/main/fonts/MaterialCommunityIcons.ttfUpdate
Check your
android/app/src/main/fontsdirectory, if the following files exist, just delete them:AntDesign.ttfEntypo.ttfEvilIcons.ttfFeather.ttfFontAwesome.ttfFontAwesome5_Brands.ttfFontAwesome5_Regular.ttfFontAwesome5_Solid.ttfFontisto.ttfFoundation.ttfIonicons.ttfMaterialCommunityIcons.ttfMaterialIcons.ttfOcticons.ttfSimpleLineIcons.ttfZocial.ttfI’ve had the same issue and
react-native unlink react-native-vector-iconsworked for me (I’m a noob and this was the answer I was looking for).USE npx react-native-asset
Going to close this here as double-inclusion is an integrator problem, not a module problem, but perhaps this issue existing historically will help others if they have incorrectly double-included vector icons like I/we have in those templates, I’m tracking it now in those two template repos
Thanks for the help, and for react-native-vector-icons in general @oblador - much appreciated!
I think the answer here is: never ever ever ever ever ever use
react-native linkIt is deprecated forever, and is specifically removed in the CLI now. No one should ever use react-native link.
Don’t use react-native link
I’m repeating myself in humor, but seriously, don’t use it 😃
https://github.com/react-native-community/cli/pull/1537
Hi. I have the same problem:
When I want to build my project on gitlab runner I have this problem. When I use this command :
react-native unlink react-native-vector-iconsthis lead to clean all fonts inandroid/app/src/main/assets/fontsand the problem is disappeared and build correctly. but in , for example, Samsung A51 keyboard will not work correctly! (disappear when user wants to type) So I can not remove fonts fromandroid/app/src/main/assets/fonts. Now my question is : Why fonts are created automatically in pathandroid/app/build/intermediates/ReactNativeVectorIcons/fonts? and How can I solve my problem? I really stopped on this bug. Thanks in advancedOnce again @mikehardy you saved me hours of my life. ❤️
I think you may have sniped it! I normally (that is: in all my other projects) just use the gradle file reference as I included at the bottom of the report, but in this particular one I have them in assets as well:
This project is based off a chain of templates that I attempt to keep maintained as starters for others, and they sadly suffer the same pathology: https://github.com/invertase/react-native-firebase-authentication-example/tree/main/template/android/app/src/main/assets/fonts https://github.com/plaut-ro/luna/tree/master/template/android/app/src/main/assets/fonts
So we have some fixing to do I suppose. It doesn’t appear that this is react-native-vector-icons fault, though it is kind of a build break - if I’m understanding it correctly we were just getting lucky before that the build.gradle machinery from here was effectively overwriting the fonts we were already including as source and we were just lucky before because they were in the same spot.
Not sure if I’m missing something here, but I did not have any icons duplicated in my android/ or src/ files.
I am running the following react-native-config.js to only copy over the icons I actually need:
And I have this in my build.gradle:
…and I get the duplicate resources errors when building. When removing my custom react-native-config, all icons get copied over and I still get the build error… 🤔
Am I doing something wrong? @oblador
nodemudules> react-native-vector-icons/font.gradle
Solved by changing the path :
from : into “$buildDir/intermediates/ReactNativeVectorIcons/fonts”
to: into “$buildDir/intermediates/assets/fonts”
I’m only using the recommended gradle method and my
android/app/src/main/assets/fontsis empty but I’m still getting the error:Any recommendations?
Yeah, and you can probably earn all sorts of Internet Points (worth more than bitcoin right now!) if you post some updated answers on the relevant stack overflow - I just know this is going to bite a ton of people
My problem solved with this : https://github.com/facebook/react-native/issues/33164
Anybody can not answer my question ? 😦 In my system I do not have any problem, but I do not know why git lab runner create folder
ReactNativeVectorIconsin pathandroid/app/build/intermediatesand copy fonts there !!!Thank you so much
@oblador yes, I tried only the Gradle approach (no custom RN config), as well as the custom RN config (no Gradle) approach, both with a complete nuke & clean install, but still all fonts were copied over. I’ll provide a repro once I got some time 🙏
hm, that still copies over all icons? I’ll try to build a clean reproduceable sample.