Closed hengkx closed 11 months ago
also experiencing this issue with my project. rolling back the gradle version seems to have fixed it for now, but that's not a long term solution
EDIT: after rolling back the gradle version, the build succeeded but my app is crashing. not sure if the crash is related to the project or not though.
diff --git a/node_modules/react-native-vector-icons/fonts.gradle b/node_modules/react-native-vector-icons/fonts.gradle
index 5485fac..5b6a5bc 100644
--- a/node_modules/react-native-vector-icons/fonts.gradle
+++ b/node_modules/react-native-vector-icons/fonts.gradle
@@ -7,14 +7,12 @@ android.sourceSets.main.assets.srcDirs += file("$buildDir/intermediates/ReactNat
* Task to copy icon font files
*/
afterEvaluate {
- def config = project.hasProperty("vectoricons") ? project.vectoricons : [];
- def iconFontsDir = config.iconFontsDir ?: "../../node_modules/react-native-vector-icons/Fonts";
- def iconFontNames = config.iconFontNames ?: [ "*.ttf" ];
+ def config = project.hasProperty("vectoricons") ? project.vectoricons : []
+ def iconFontsDir = config.iconFontsDir ?: "../../node_modules/react-native-vector-icons/Fonts"
+ def iconFontNames = config.iconFontNames ?: ["*.ttf"]
- def fontCopyTask = tasks.create(
- name: "copyReactNativeVectorIconFonts",
- type: Copy) {
- description = "copy vector icon fonts."
+ tasks.register("copyReactNativeVectorIconFonts", Copy) {
+ description = "copy vector icon fonts"
into "$buildDir/intermediates/ReactNativeVectorIcons/fonts"
iconFontNames.each { fontName ->
@@ -24,9 +22,11 @@ afterEvaluate {
}
}
- android.applicationVariants.all { def variant ->
- def targetName = variant.name.capitalize()
- def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
- generateAssetsTask.dependsOn(fontCopyTask)
+ tasks.named("lintVitalAnalyzeRelease") {
+ dependsOn(tasks.named("copyReactNativeVectorIconFonts"))
+ }
+
+ tasks.named("mergeReleaseAssets") {
+ dependsOn(tasks.named("copyReactNativeVectorIconFonts"))
}
}
\ No newline at end of file
I have the same problem with react-native: 0.72.0
EDIT: Waiting for a new version, the patch from @hengkx solve the problem on the build but but any icon is display on android !
Here is a simpler patch that works for variants on RN 0.72, not sure if it is best the way of fixing it but it may help for the version that will land in the source code. I didn't noticed any issue on icon displayed on android.
diff --git a/node_modules/react-native-vector-icons/fonts.gradle b/node_modules/react-native-vector-icons/fonts.gradle
index 5485fac..ef3ccb3 100644
--- a/node_modules/react-native-vector-icons/fonts.gradle
+++ b/node_modules/react-native-vector-icons/fonts.gradle
@@ -26,6 +26,10 @@ afterEvaluate {
android.applicationVariants.all { def variant ->
def targetName = variant.name.capitalize()
+ def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")
+ if (lintVitalAnalyzeTask) {
+ lintVitalAnalyzeTask.dependsOn(fontCopyTask)
+ }
def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
generateAssetsTask.dependsOn(fontCopyTask)
}
@benoitvallon's patch solved the problem for me, I have multiple app variants and @hengkx didn't work for me because of that. But with this one https://github.com/oblador/react-native-vector-icons/issues/1508#issuecomment-1604115239 I was able to build the APK and didn't notice any problem with the icons when running on the device. Waiting for a definitive fix to arrive
did anyone find solution
as I run ./gradlew build everytime I get this error
A problem was found with the configuration of task ':app:lintVitalAnalyzeRelease' (type 'AndroidLintAnalysisTask').
Gradle detected a problem with the following location: 'C:\Users\abhij\OneDrive\Desktop\bahikhata\android\app\build\intermediates\ReactNativeVectorIcons'.
Reason: Task ':app:lintVitalAnalyzeRelease' uses this output of task ':app:copyReactNativeVectorIconFonts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.
with RN v 0.72
@abhijain1705 have you tried the patches above? They seem to work
not yet, I am confused where do I need to add these lines @efstathiosntonas could you please help me?
@abhijain1705 You should look up https://www.npmjs.com/package/patch-package or Yarn's own patching mechanism (https://yarnpkg.com/cli/patch) if you're using it instead of NPM. I don't know exactly in which version of Yarn that was introduced but I'm using Yarn v3.x and it works. You should go through the docs of either of them and get to the step where you edit the external package's source files. Then you'd go to the fonts.gradle
file inside the react-native-vector-icons
and add the lines mentioned in @benoitvallon's patch, these:
+ def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")
+ if (lintVitalAnalyzeTask) {
+ lintVitalAnalyzeTask.dependsOn(fontCopyTask)
+ }
After completing the process following either the patch-package
lib or Yarn's patch
command, you should be ready to go
let me try
hey @efstathiosntonas
my ./gradlew build failed with these errors
Task :app:lintAnalyzeDebug FAILED
FAILURE: Build failed with an exception.
What went wrong: A problem was found with the configuration of task ':app:lintAnalyzeDebug' (type 'AndroidLintAnalysisTask').
Reason: Task ':app:lintAnalyzeDebug' uses this output of task ':app:copyReactNativeVectorIconFonts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 12m 16s 752 actionable tasks: 649 executed, 103 up-to-date
would you help me on this
Same issue.
react native 0.72
I have been getting this when building using fastlane to make a release build.
Initially I was getting this error for the task :app:lintVitalReportRelease
so I applied a patch similar to the one linked here
Afterwards I got the same error posted by OP, so in the end the patch that worked for me was declaring an explicit dependency for both the lintVitalReport${targetName}
and lintVitalAnalyze${targetName}
tasks:
diff --git a/node_modules/react-native-vector-icons/fonts.gradle b/node_modules/react-native-vector-icons/fonts.gradle
index 5485fac..cf5262c 100644
--- a/node_modules/react-native-vector-icons/fonts.gradle
+++ b/node_modules/react-native-vector-icons/fonts.gradle
@@ -26,6 +26,14 @@ afterEvaluate {
android.applicationVariants.all { def variant ->
def targetName = variant.name.capitalize()
+ def lintVitalReportTask = tasks.findByName("lintVitalReport${targetName}")
+ if(lintVitalReportTask) {
+ lintVitalReportTask.dependsOn(fontCopyTask)
+ }
+ def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")
+ if(lintVitalAnalyzeTask) {
+ lintVitalAnalyzeTask.dependsOn(fontCopyTask)
+ }
def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
generateAssetsTask.dependsOn(fontCopyTask)
}
The patch from https://github.com/oblador/react-native-vector-icons/issues/1508#issuecomment-1604115239 works perfectly. Thanks @benoitvallon
Here is a simpler patch that works for variants on RN 0.72, not sure if it is best the way of fixing it but it may help for the version that will land in the source code. I didn't noticed any issue on icon displayed on android.
diff --git a/node_modules/react-native-vector-icons/fonts.gradle b/node_modules/react-native-vector-icons/fonts.gradle index 5485fac..ef3ccb3 100644 --- a/node_modules/react-native-vector-icons/fonts.gradle +++ b/node_modules/react-native-vector-icons/fonts.gradle @@ -26,6 +26,10 @@ afterEvaluate { android.applicationVariants.all { def variant -> def targetName = variant.name.capitalize() + def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}") + if (lintVitalAnalyzeTask) { + lintVitalAnalyzeTask.dependsOn(fontCopyTask) + } def generateAssetsTask = tasks.findByName("generate${targetName}Assets") generateAssetsTask.dependsOn(fontCopyTask) }
The patch work for me, thanks!!
Task :app:lintAnalyzeDebug FAILED
FAILURE: Build failed with an exception.
- What went wrong: A problem was found with the configuration of task ':app:lintAnalyzeDebug' (type 'AndroidLintAnalysisTask').
I also got this error and hotfixed it, but lintAnalyzeDebug
seems to take longer to finish running.
diff --git a/node_modules/react-native-vector-icons/fonts.gradle b/node_modules/react-native-vector-icons/fonts.gradle
index 5485fac..7b8c6ca 100644
--- a/node_modules/react-native-vector-icons/fonts.gradle
+++ b/node_modules/react-native-vector-icons/fonts.gradle
@@ -26,6 +26,18 @@ afterEvaluate {
android.applicationVariants.all { def variant ->
def targetName = variant.name.capitalize()
+ def lintVitalReportTask = tasks.findByName("lintVitalReport${targetName}")
+ if(lintVitalReportTask) {
+ lintVitalReportTask.dependsOn(fontCopyTask)
+ }
+ def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")
+ if(lintVitalAnalyzeTask) {
+ lintVitalAnalyzeTask.dependsOn(fontCopyTask)
+ }
+ def lintAnalyzeTask = tasks.findByName("lintAnalyze${targetName}")
+ if(lintAnalyzeTask) {
+ lintAnalyzeTask.dependsOn(fontCopyTask)
+ }
def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
generateAssetsTask.dependsOn(fontCopyTask)
}
https://github.com/oblador/react-native-vector-icons/issues/1508#issuecomment-1606108215 It does works on my project with RN 0.72.1 and yarn 1.22.19
Its not a right method to update node_modules and also its not working for me. @benoitvallon
I am using React native v0.72 downgrading the gradle version one step fixed my issue
from gradle v8.2 -> v7.6.2
change distributionUrl in android/gradle/wrapper/gradle-wraper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-all.zip
Here is a simpler patch that works for variants on RN 0.72, not sure if it is best the way of fixing it but it may help for the version that will land in the source code. I didn't noticed any issue on icon displayed on android.
diff --git a/node_modules/react-native-vector-icons/fonts.gradle b/node_modules/react-native-vector-icons/fonts.gradle index 5485fac..ef3ccb3 100644 --- a/node_modules/react-native-vector-icons/fonts.gradle +++ b/node_modules/react-native-vector-icons/fonts.gradle @@ -26,6 +26,10 @@ afterEvaluate { android.applicationVariants.all { def variant -> def targetName = variant.name.capitalize() + def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}") + if (lintVitalAnalyzeTask) { + lintVitalAnalyzeTask.dependsOn(fontCopyTask) + } def generateAssetsTask = tasks.findByName("generate${targetName}Assets") generateAssetsTask.dependsOn(fontCopyTask) }
working fine after added this inside vector-icons node_modules
Here is a simpler patch that works for variants on RN 0.72, not sure if it is best the way of fixing it but it may help for the version that will land in the source code. I didn't noticed any issue on icon displayed on android.
diff --git a/node_modules/react-native-vector-icons/fonts.gradle b/node_modules/react-native-vector-icons/fonts.gradle index 5485fac..ef3ccb3 100644 --- a/node_modules/react-native-vector-icons/fonts.gradle +++ b/node_modules/react-native-vector-icons/fonts.gradle @@ -26,6 +26,10 @@ afterEvaluate { android.applicationVariants.all { def variant -> def targetName = variant.name.capitalize() + def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}") + if (lintVitalAnalyzeTask) { + lintVitalAnalyzeTask.dependsOn(fontCopyTask) + } def generateAssetsTask = tasks.findByName("generate${targetName}Assets") generateAssetsTask.dependsOn(fontCopyTask) }
Solved the problem for me.
not yet, I am confused where do I need to add these lines @efstathiosntonas could you please help me?
1. Look, find fonts.gradle file from nodemodules> react-native-vector-icons >fonts.gradle:
you will find an object in fonts.gradle i.e: 'afterEvaluate' like this:
afterEvaluate { def config = project.hasProperty("vectoricons") ? project.vectoricons : []; def iconFontsDir = config.iconFontsDir ?: "../../node_modules/react-native-vector-icons/Fonts"; def iconFontNames = config.iconFontNames ?: [ "*.ttf" ];
def fontCopyTask = tasks.create(
name: "copyReactNativeVectorIconFonts",
type: Copy) {
description = "copy vector icon fonts."
into "$buildDir/intermediates/ReactNativeVectorIcons/fonts"
iconFontNames.each { fontName ->
from(iconFontsDir) {
include(fontName)
}
}
}
2. Now need to add these lines of code init:
android.applicationVariants.all { def variant -> def targetName = variant.name.capitalize() def generateAssetsTask = tasks.findByName("generate${targetName}Assets") generateAssetsTask.dependsOn(fontCopyTask) }
3. This will turn out like this:
afterEvaluate { def config = project.hasProperty("vectoricons") ? project.vectoricons : []; def iconFontsDir = config.iconFontsDir ?: "../../node_modules/react-native-vector-icons/Fonts"; def iconFontNames = config.iconFontNames ?: [ "*.ttf" ];
def fontCopyTask = tasks.create(
name: "copyReactNativeVectorIconFonts",
type: Copy) {
description = "copy vector icon fonts."
into "$buildDir/intermediates/ReactNativeVectorIcons/fonts"
iconFontNames.each { fontName ->
from(iconFontsDir) {
include(fontName)
}
}
}
android.applicationVariants.all { def variant ->
def targetName = variant.name.capitalize()
def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
generateAssetsTask.dependsOn(fontCopyTask)
}
}
4.Then create a build again.
I hope this will help :)
I have the same problem with react-native: 0.72.0
But after many searching and analysing i find out solution:-
Just remove this line from android/app/build.gradle
project.ext.vectoricons = [
iconFontNames: [ 'EvilIcons.ttf', 'FontAwesome.ttf', '.......' ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
2.
And you can add use vector icon or fonts file manually at android/app/arc/main/assets/fonts/...hear
or
Asset refresh and Add in android-assets folder and iOS-info file direct
npx react-native-asset
“https://blog.devgenius.io/implement-custom-fonts-on-react-native-0-70-649c16f7609f”
@Hit-Opash This is not recommended as it makes upgrading harder. Is the fix in 10.0.0 not working for you?
This is work for me because I added assets -> fonts -> .ttf file. folder using npx react-native-asset . so I'dont need to add manually at android/app/build.gradle.
And write not https://oblador.github.io/react-native-vector-icons/
website not working
I had a similar problem in version 10.0.0
A problem was found with the configuration of task ':app:lintAnalyzeDebug' (type 'AndroidLintAnalysisTask').
- Gradle detected a problem with the following location: '/Users/vsastra/Desktop/Work/mochi/mobile/android/app/build/intermediates/ReactNativeVectorIcons'.
Reason: Task ':app:lintAnalyzeDebug' uses this output of task ':app:copyReactNativeVectorIconFonts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
1. Declare task ':app:copyReactNativeVectorIconFonts' as an input of ':app:lintAnalyzeDebug'.
2. Declare an explicit dependency on ':app:copyReactNativeVectorIconFonts' from ':app:lintAnalyzeDebug' using Task#dependsOn.
3. Declare an explicit dependency on ':app:copyReactNativeVectorIconFonts' from ':app:lintAnalyzeDebug' using Task#mustRunAfter.
So I add a similar fix to https://github.com/oblador/react-native-vector-icons/issues/1508#issuecomment-1604115239 by adding the following lines to node_modules/react-native-vector-icons/fonts.gradle
def lintAnalyzeTask = tasks.findByName("lintAnalyze${targetName}")
lintAnalyzeTask?.dependsOn(fontCopyTask)
@oblador This is not recommended as it makes upgrading harder. Is the fix in 10.0.0 not working for you?
Same problem in 10.0.0 im afraid. Running on react-native 0.72.3.
new version work well.
@oblador
I ran into the same issue today with ./gradlew build failing. react-native 0.72.3 react-native-vector-icons 10.0.0 Gradle 8.0.1
The patch suggested by @VincentSastra worked for me, i.e. adding
def lintAnalyzeTask = tasks.findByName("lintAnalyze${targetName}")
lintAnalyzeTask?.dependsOn(fontCopyTask)
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip // # distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
works with Gradle version 7.5.1 on RN 072.4 and react-native-vector-icons 10.0.0
i think just install latest version of react-native-vector-icons , it works for me.
i was getting same error.
I'm using RN 0.73 and when i updated to 10.0.0 works fine.
@ManeeshNadcab @tuiza To fix this ,follow these step 1) remove apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle") from android/app/build.gradlew 2) go to node_modules/react-native-vector-icon/Fonts and copy all the fonts 3) go to android/app/src/main and create a folder named assets if not exist then inside then assets create one more folder named fonts and paste all the fonts from node_modules/react-native-vector-icon/Fonts to here 4) now you can use the vector icon as usual and also you can create a build which won't failed
@ManeeshNadcab @tuiza To fix this ,follow these step
- remove apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle") from android/app/build.gradlew
- go to node_modules/react-native-vector-icon/Fonts and copy all the fonts
- go to android/app/src/main and create a folder named assets if not exist then inside then assets create one more folder named fonts and paste all the fonts from node_modules/react-native-vector-icon/Fonts to here
- now you can use the vector icon as usual and also you can create a build which won't failed
This works
@krmahil Welcome
There is a PR that will solve this here. Can we not have this merged in, please?
@ManeeshNadcab @tuiza To fix this ,follow these step
- remove apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle") from android/app/build.gradlew
- go to node_modules/react-native-vector-icon/Fonts and copy all the fonts
- go to android/app/src/main and create a folder named assets if not exist then inside then assets create one more folder named fonts and paste all the fonts from node_modules/react-native-vector-icon/Fonts to here
- now you can use the vector icon as usual and also you can create a build which won't failed
Works Perfectly for me. Thanks! Note that this issue persists on RN 0.74.0 with react-native-vector-icons v10.0.3
@ergen35 Welcome, Happy to help, if you don't mind can you check my work ?
Environment
Description
Describe your issue in detail. Include screenshots if needed.
Reproducible Demo
Let us know how to reproduce the issue. Include a code sample, share a project, or share an app that reproduces the issue using https://snack.expo.io/. Please follow the guidelines for providing a MCVE: https://stackoverflow.com/help/mcve
FAILURE: Build failed with an exception.
What went wrong: A problem was found with the configuration of task ':app:lintVitalAnalyzeRelease' (type 'AndroidLintAnalysisTask').
Reason: Task ':app:lintVitalAnalyzeRelease' uses this output of task ':app:copyReactNativeVectorIconFonts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
Possible solutions:
Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.
Try:
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/8.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1m 33s
https://github.com/facebook/react-native/issues/37815