react-native-vector-icons icon indicating copy to clipboard operation
react-native-vector-icons copied to clipboard

[Bug]: 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.

Open makhoulshbeeb opened this issue 10 months ago • 4 comments

Which package are you using?

@react-native-vector-icons/*

What platform(s) does this occur on?

Android

What happened?

Build failure when running "./gradlew build" on android directory

Fix:

Under "android.applicationVariants.all { def variant ->" in "fonts.gradle" add:

def lintAnalyzeTask = tasks.findByName("lintAnalyze${targetName}") lintAnalyzeTask?.dependsOn(copyReactNativeVectorIconFonts)

Relevant log output

No response

Minimal reproducible example

No response

Your computer environment

System:
  OS: Linux 6.8 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
  CPU: (22) x64 Intel(R) Core(TM) Ultra 7 155H
  Memory: 3.89 GB / 15.09 GB
  Shell:
    version: 5.2.21
    path: /bin/bash
Binaries:
  Node:
    version: 23.4.0
    path: ~/.nvm/versions/node/v23.4.0/bin/node
  Yarn: Not Found
  npm:
    version: 10.9.2
    path: ~/.nvm/versions/node/v23.4.0/bin/npm
  Watchman:
    version: 4.9.0
    path: /usr/bin/watchman
SDKs:
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
Languages:
  Java:
    version: 23.0.1
    path: /usr/bin/javac
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: ^18.2.0
  react-native:
    installed: 0.72.7
    wanted: 0.72.7
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: Not found

makhoulshbeeb avatar Jan 14 '25 14:01 makhoulshbeeb

@makhoulshbeeb Can you migrate to @react-native-vector-icons/* v11.x

It copies the fonts in a different way that solves this issue

johnf avatar Jan 24 '25 23:01 johnf

Hi @johnf, I'm facing the same issue with react-native-vector-icons v10.2.0.

I can't migrate to @react-native-vector-icons/ v11.x since I'm using react-native-vector-icons as a dependency of React Native Elements.

Is there a way to properly copy the fonts without migrating?

MatthieuCutin avatar Feb 18 '25 09:02 MatthieuCutin

@MatthieuCutin Would you be able to share a repro?

We've come across this issue in 10.x a few times, but it's hard to nail down why it affects some folks and not others

johnf avatar Mar 01 '25 03:03 johnf

For anyone still facing this issue, the following solved it for a project I work on and may work for you. In my case we had a different task that was flagged as being dependent oncopyReactNativeVectorIconFonts, but the error was nearly identical:

* What went wrong:
A problem was found with the configuration of task ':app:copyReactNativeVectorIconFonts' (type 'Copy').
  - Gradle detected a problem with the following location: '{PROJECT_PATH}/android/app/build/intermediates/ReactNativeVectorIcons/fonts'.

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

    For more information, please refer to https://docs.gradle.org/8.10.2/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

To fix this, as the "Possible solutions" section indicates, you can try to declare an explicit dependency on the :app:copyReactNativeVectorIconFonts task for the :app:generateReleaseStoreLintVitalReportModel task. In OPs case, the task would be :app:lintAnalyzeDebug, but the solution is the same.

Within ./android/app/build.gradle, try adding the following to declare the dependency for the task:

android {
    // ...existing code...

    tasks.whenTaskAdded { task ->
        // Change the task name here to the task from your error message, for OP this would be 'lintAnalyzeDebug'
        if (task.name == 'generateReleaseStoreLintVitalReportModel') { 
            task.dependsOn 'copyReactNativeVectorIconFonts'
        }
    }
}

This code snippet ensures that the generateReleaseStoreLintVitalReportModel task depends on the copyReactNativeVectorIconFonts task, which should resolve the issue.

Hope that helps!

sforsberg avatar Mar 21 '25 14:03 sforsberg

Please upgrade to RNVI 12.x which takes a different approach. You'll need to follow the migration guide

johnf avatar Jul 12 '25 13:07 johnf