-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[solved] Duplicate resources android build error with v9.1.0 - [fonts were in source tree *and* using module's build.gradle font copy] #1416
Comments
Do you by any chance have them in your own project's fonts folder too? |
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 |
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: 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. |
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! |
Same problem in v9.1.0, removing them will work again:
Update Check your
|
@lyswhut I do not believe this is a module problem at all based on @oblador's response, and it appears you have the same thing - fonts in the source tree and fonts copied via use of the build.gradle script reference to this module's build.gradle that copies fonts. As Joel said, we (as users of react-native-vector-icons) have to choose one style or the other - that it worked before was kind of just coincidence and at least for the projects I'm working on I accept I was doing it wrong and need to use the module correctly... |
Once again @mikehardy you saved me hours of my life. ❤️ |
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: const VECTOR_ICONS_FONTS_PATH = './node_modules/react-native-vector-icons/Fonts'
const VECTOR_FONTS = ['Ionicons.ttf']
module.exports = {
project: {
ios: {},
android: {},
},
dependencies: {
// Disable auto linking for `react-native-vector-icons` and link
// the required fonts manually to avoid duplicate resources issue in iOS.
'react-native-vector-icons': {
platforms: {
ios: null,
android: null,
},
assets: VECTOR_FONTS.map((font) => VECTOR_ICONS_FONTS_PATH + '/' + font),
},
},
assets: ['./src/assets/fonts/'], // stays the same
} And I have this in my build.gradle: project.ext.vectoricons = [
iconFontNames: [
'Ionicons.ttf',
]
] ..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 |
@mrousavy You need to pick one approach, either the gradle one or RN autolinking. In this case I would suggest that you keep gradle only to make sure you get the right version. |
hm, that still copies over all icons? |
can you tell me the version in which it is resolved |
@shagun-firstlight as far as I can tell - @mrousavy's comment notwithstanding since he may have a reproduction of erroneous behavior - this is a project-specific problem and the resolution will be in your project. 9.1.0 introduced this behavior that exposed project-specific issues, and there has been no release since. |
I've had the same issue and |
@mrousavy No, you can define an array of which fonts to copy. Are you saying you are not using the gradle file, have no fonts in your android project and still get this error? |
@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. |
Thank you so much |
Why does this problem occur? react-native link and after react-native unlink react-native-vector-icons seems to work. |
Hi. I have the same problem:
When I want to build my project on gitlab runner I have this problem. |
finally sorted out, thank you |
Anybody can not answer my question ? :( |
@samaneh-kamalian try this solution |
Thanks for your reply. |
My problem solved with this : facebook/react-native#33164 |
thanks so much , its save my day |
Thanks so much. This worked for me. I had to write it as |
I'm trying to only use one approach (Gradle) but I can't make module.exports = {
dependencies: {
'react-native-vector-icons': {
platforms: {
ios: null,
android: null,
},
},
},
project: {
ios: {},
android: {},
},
assets: ['./assets/fonts/'],
}; |
I think the answer here is: never ever ever ever ever ever use It 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 :-) |
@mikehardy I'm happy to include my other (non react-native-vector-icons) fonts in whatever is the recommended way. I have't found a tutorial that doesn't use |
I'm sorry (especially since my previous comment is a bit joking but also shows that they actually removed link) - I don't do anything that requires or required link myself so I have never looked in to it. I checked that PR and see it was brought up as a concern: react-native-community/cli#1537 (review) I think you have to do in your source tree what link was doing for you: Then refer to it by name in vector icons to load it and use it ? This is untested, just trying to be helpful (and also stitch together this issue and the react-native CLI discussion) |
For iOS at least, you can create a resources podspec, e.g.: Pod::Spec.new do |s|
s.name = 'MyResources'
s.version = '1.0.0'
...
s.resources = 'assets/fonts/*'
end For Android, it's a little more complicated. You can probably write some Gradle scripts to copy them into place, but it's not very elegant. |
This would probably be a useful general purpose module really, with |
Re what to use instead of |
That looks perfect @liamjones - for the new react-native CLI upcoming, since link is going away completely - this could serve as a good time to update the docs now if you have a flow you've tested + know works for custom fonts |
@mikehardy the docs for |
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 |
I'm only using the recommended gradle method and my
Any recommendations? |
USE npx react-native-asset |
It worked Thank you so much. |
Thank you. Just rolled a new react-native project and setting up this library did not work at all. The issue was that the .sh script which is used to upgrade to Pro uses react-native link, which literally doesn't exist anymore. |
I hope this email finds you well. I wanted to share an informative blog post with you that I recently came across. Here i provide proper solution. In above example i check. Initially worked but when build upload that's time create issue. |
nodemudules> react-native-vector-icons/font.gradle Solved by changing the path : from : to: |
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
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 momentI am not including specific fonts, the tail of my
android/app/build.gradle
is:The text was updated successfully, but these errors were encountered: