Task :app:copyReactNativeVectorIconFonts FAILED
Asked Answered
L

8

8

Hello i programing a react-native which assembleDebug work but assembleRealease dont. i dont know why this happen & i solutions on internet dont work

What can i do?

> Task :app:copyReactNativeVectorIconFonts FAILED                                                                                                  

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':app:copyReactNativeVectorIconFonts' (type 'Copy').
  - Gradle detected a problem with the following location: 'D:\Cosas\UTN\APPMOVIL\HayEquipo\hayEquipo\android\app\build\intermediates\ReactNativeVectorIcons\fonts'.

    Reason: Task ':app:lintVitalReportRelease' 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:lintVitalReportRelease'.
      2. Declare an explicit dependency on ':app:copyReactNativeVectorIconFonts' from ':app:lintVitalReportRelease' using Task#dependsOn.
      3. Declare an explicit dependency on ':app:copyReactNativeVectorIconFonts' from ':app:lintVitalReportRelease' using Task#mustRunAfter.       

    Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.      
  - Gradle detected a problem with the following location: 'D:\Cosas\UTN\APPMOVIL\HayEquipo\hayEquipo\android\app\build\intermediates\ReactNativeVectorIcons\fonts'.

    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:
      1. Declare task ':app:copyReactNativeVectorIconFonts' as an input of ':app:lintVitalAnalyzeRelease'.
      2. Declare an explicit dependency on ':app:copyReactNativeVectorIconFonts' from ':app:lintVitalAnalyzeRelease' using Task#dependsOn.
      3. Declare an explicit dependency on ':app:copyReactNativeVectorIconFonts' from ':app:lintVitalAnalyzeRelease' using Task#mustRunAfter.      

    Please refer to https://docs.gradle.org/8.0.1/userguide/validation_problems.html#implicit_dependency for more details about this problem.      

BUILD FAILED in 1m 6s
318 actionable tasks: 14 executed, 304 up-to-date
Louella answered 9/7, 2023 at 20:9 Comment(0)
J
20

Here is the Patch to this Error: path: "your project folder"/node_modules/react-native-vector-icons/fonts.gradle.

Apply these changes:

afterEvaluate {
// ...

    android.applicationVariants.all { def variant ->
        def targetName = variant.name.capitalize()
        def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")  // here
            if (lintVitalAnalyzeTask) {  // here
                lintVitalAnalyzeTask.dependsOn(fontCopyTask) //here
            } // here
        def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
        generateAssetsTask.dependsOn(fontCopyTask)
    }
}

edit- Upvote if you find this helpful, :)

Jenine answered 11/7, 2023 at 4:35 Comment(0)
E
11

This solution will work 100%

Remove below config from android/app/build.gradle

apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")

then copy all fonts from

/node_modules/react-native-vector-icons/Fonts

enter image description here

to

android/app/src/main/assets/fonts (create new if not exist)

enter image description here

Excruciating answered 19/4 at 3:56 Comment(2)
Could you please explain why it worked?Maravedi
the solution is quite simple, we just do the task by manually since the script cannot work due to an exceptionExcruciating
C
8

I encountered the same error and simply ran 'yarn add react-native-vector-icons' in the root folder to fix it.

Cahra answered 1/8, 2023 at 18:14 Comment(3)
The above is the recommended fix instead of the patch and it works because it updates to the latest version of react-native-vector-icons which contains the fix.Nerva
I had run 'yarn add react-native-vector-icons' , still it throws error while running "gradlew build". I had checked the file "your project folder"/node_modules/react-native-vector-icons/fonts.gradle" and patch applied. any suggestion.Ludicrous
worked beautifully. thank youBlackjack
E
1

As of version 10.0.2, I also had to add to the fix above ( first fix was already in 10.0.2 ) :

def lintAnalyzeTask = tasks.findByName("lintAnalyze${targetName}")
    lintAnalyzeTask?.dependsOn(copyReactNativeVectorIconFonts)
Elaina answered 26/1 at 2:29 Comment(0)
W
1

For React Native 0.74.x you will need to apply the following patch:

--- a/node_modules/react-native-vector-icons/fonts.gradle
+++ b/node_modules/react-native-vector-icons/fonts.gradle
@@ -26,18 +26,28 @@ afterEvaluate {

     android.applicationVariants.all { def variant ->
         def targetName = variant.name.capitalize()
-        def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")

+        def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")
         if (lintVitalAnalyzeTask) {
-        lintVitalAnalyzeTask.dependsOn(fontCopyTask)
+            lintVitalAnalyzeTask.dependsOn(fontCopyTask)
+        }
+
+        def lintAnalyzeTask = tasks.findByName("lintAnalyze${targetName}")
+        if (lintAnalyzeTask) {
+            lintAnalyzeTask.dependsOn(fontCopyTask)
         }

-        def generateReportTask = tasks.findByName("generate${targetName}LintVitalReportModel")
+        def generateVitalReportTask = tasks.findByName("generate${targetName}LintVitalReportModel")
+        if (generateVitalReportTask) {
+            generateVitalReportTask.dependsOn(fontCopyTask)
+        }
+
+        def generateReportTask = tasks.findByName("generate${targetName}LintReportModel")
         if (generateReportTask) {
             generateReportTask.dependsOn(fontCopyTask)
         }

         def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
         generateAssetsTask.dependsOn(fontCopyTask)
-      }
+    }
 }

It seems as though the lint task names have changed when going from gradle 8.3 to 8.6.

Whereinto answered 8/7 at 10:31 Comment(0)
P
0

The accepted answer did not work for me. To circumvent this bug, you must declare explicit task dependencies for the debug and release tasks.

Navigate to node_modules/react-native-vector-icons/fonts.gradle and modify android.applicationVariants.all {...}

    android.applicationVariants.all { def variant ->
        def targetName = variant.name.capitalize()

        def lintAnalyzeDebugTask = tasks.findByName("lintAnalyzeDebug")
        if (lintAnalyzeDebugTask) {
            lintAnalyzeDebugTask.dependsOn(fontCopyTask)
            lintAnalyzeDebugTask.mustRunAfter(fontCopyTask)
        }

        def lintVitalAnalyzeReleaseTask = tasks.findByName("lintVitalAnalyzeRelease")
        if (lintVitalAnalyzeReleaseTask) {
            lintVitalAnalyzeReleaseTask.dependsOn(fontCopyTask)
            lintVitalAnalyzeReleaseTask.mustRunAfter(fontCopyTask)
        }

        def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
        generateAssetsTask.dependsOn(fontCopyTask)
    }
Phlegethon answered 7/3 at 20:38 Comment(0)
T
0

Yo trabajo con RN 0.73 y tuve el mismo error pero registre en \node_modules\react-native-vector-icons\fonts.gradle el siguiente codigo:

    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)
    }
Togetherness answered 12/6 at 13:24 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Foofaraw
stackoverflow.com/help/non-english-questionsMaryjanemaryjo
D
-1

It worked on RN 0.74.0

just add at \node_modules\react-native-vector-icons\fonts.gradle

if (lintVitalAnalyzeTask) {
        lintVitalAnalyzeTask.dependsOn(fontCopyTask)
        }

+        def generateReportTask = tasks.findByName("generate${targetName}LintVitalReportModel")
+      if (generateReportTask) {
+            generateReportTask.dependsOn(fontCopyTask)
+      }

        def generateAssetsTask = tasks.findByName("generate${targetName}Assets")
        generateAssetsTask.dependsOn(fontCopyTask)
Dogeared answered 25/4 at 10:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.