oblador / react-native-vector-icons

Customizable Icons for React Native with support for image source and full styling.
https://oblador.github.io/react-native-vector-icons/
MIT License
17.31k stars 2.12k forks source link

react native 0.72-rc6 android relase error #1508

Closed hengkx closed 11 months ago

hengkx commented 1 year ago

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

Task :app:lintVitalAnalyzeRelease FAILED

FAILURE: Build failed with an exception.

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

masonjenkins commented 1 year 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.

hengkx commented 1 year ago
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
clementnv commented 1 year ago

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 !

benoitvallon commented 1 year ago

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)
     }
Risovas commented 1 year ago

@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

abhijain1705 commented 1 year ago

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').

efstathiosntonas commented 1 year ago

@abhijain1705 have you tried the patches above? They seem to work

abhijain1705 commented 1 year ago

not yet, I am confused where do I need to add these lines @efstathiosntonas could you please help me?

Risovas commented 1 year ago

@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

abhijain1705 commented 1 year ago

let me try

abhijain1705 commented 1 year ago

hey @efstathiosntonas

my ./gradlew build failed with these errors

Task :app:lintAnalyzeDebug FAILED

FAILURE: Build failed with an exception.

BUILD FAILED in 12m 16s 752 actionable tasks: 649 executed, 103 up-to-date

would you help me on this

mMarcos208 commented 1 year ago

Same issue.

react native 0.72

mariah-backbar commented 1 year ago

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)
     }
VVVi commented 1 year ago

The patch from https://github.com/oblador/react-native-vector-icons/issues/1508#issuecomment-1604115239 works perfectly. Thanks @benoitvallon

JoaoVitorJJV commented 1 year ago

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!!

qgzvcyxjfr commented 1 year ago

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)
     }
MosRat commented 1 year ago

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

imthiyazmuhammed commented 12 months ago

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

sivamani-edumpus commented 12 months ago

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)
     }
sivamani-edumpus commented 12 months ago

working fine after added this inside vector-icons node_modules

IrfanAhmadRB commented 11 months ago

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.

oblador commented 11 months ago

Fixed in 10.0.0

DevHamzaShahid commented 11 months ago

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 :)

Hit-Opash commented 11 months ago

I have the same problem with react-native: 0.72.0

But after many searching and analysing i find out solution:-

  1. 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”
oblador commented 11 months ago

@Hit-Opash This is not recommended as it makes upgrading harder. Is the fix in 10.0.0 not working for you?

Hit-Opash commented 11 months ago

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.

Hit-Opash commented 11 months ago

And write not https://oblador.github.io/react-native-vector-icons/ website not working

VincentSastra commented 11 months ago

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)
xerdnew commented 10 months ago

@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.

mMarcos208 commented 10 months ago

new version work well.

timhatch commented 10 months ago

@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)
sultanularefin commented 10 months ago

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

update just install the latest version.

ManeeshNadcab commented 8 months ago

i think just install latest version of react-native-vector-icons , it works for me.

ManeeshNadcab commented 8 months ago

i was getting same error.

tuiza commented 6 months ago

I'm using RN 0.73 and when i updated to 10.0.0 works fine.

Vimal1464 commented 6 months ago

@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

krmahil commented 5 months ago

@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

This works

Vimal1464 commented 5 months ago

@krmahil Welcome

benjanknoetze commented 3 months ago

There is a PR that will solve this here. Can we not have this merged in, please?

ergen35 commented 2 months ago

@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

Works Perfectly for me. Thanks! Note that this issue persists on RN 0.74.0 with react-native-vector-icons v10.0.3

Vimal1464 commented 2 months ago

@ergen35 Welcome, Happy to help, if you don't mind can you check my work ?