Skip to content

react native 0.72-rc6 android relase error #1508

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

Closed
2 tasks done
hengkx opened this issue Jun 20, 2023 · 42 comments
Closed
2 tasks done

react native 0.72-rc6 android relase error #1508

hengkx opened this issue Jun 20, 2023 · 42 comments

Comments

@hengkx
Copy link

hengkx commented Jun 20, 2023

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.

  • What went wrong:
    A problem was found with the configuration of task ':app:lintVitalAnalyzeRelease' (type 'AndroidLintAnalysisTask').

    • Gradle detected a problem with the following location: '/Users/tom/Documents/GitHub/media/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:

      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.

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

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

facebook/react-native#37815

@masonjenkins
Copy link

masonjenkins commented Jun 20, 2023

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

This comment was marked as outdated.

@clementnv
Copy link

clementnv commented Jun 22, 2023

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
Copy link

benoitvallon commented Jun 23, 2023

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
Copy link

Risovas commented Jun 23, 2023

@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 #1508 (comment) 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
Copy link

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:

    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.

    with RN v 0.72

@efstathiosntonas
Copy link

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

@abhijain1705
Copy link

abhijain1705 commented Jun 25, 2023

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

@Risovas
Copy link

Risovas commented Jun 25, 2023

@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
Copy link

let me try

@abhijain1705
Copy link

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

    • Gradle detected a problem with the following location: 'C:\Users\abhij\OneDrive\Desktop\bahikhata\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.

      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.

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

would you help me on this

@mMarcos208
Copy link

Same issue.

react native 0.72

@mariah-backbar
Copy link

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
Copy link

VVVi commented Jul 1, 2023

The patch from #1508 (comment) works perfectly. Thanks @benoitvallon

@JoaoVitorJJV
Copy link

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
Copy link

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
Copy link

MosRat commented Jul 3, 2023

#1508 (comment) It does works on my project with RN 0.72.1 and yarn 1.22.19

@imthiyazmuhammed
Copy link

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
Copy link

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
Copy link

working fine after added this inside vector-icons node_modules

@IrfanAhmadRB
Copy link

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
Copy link
Owner

oblador commented Jul 17, 2023

Fixed in 10.0.0

@oblador oblador closed this as completed Jul 17, 2023
@DevHamzaShahid
Copy link

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
Copy link

Hit-Opash commented Jul 19, 2023

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"
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
Copy link
Owner

oblador commented Jul 19, 2023

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

@Hit-Opash
Copy link

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
Copy link

Hit-Opash commented Jul 19, 2023

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

@VincentSastra
Copy link

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 #1508 (comment) by adding the following lines to node_modules/react-native-vector-icons/fonts.gradle

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

@xerdnew
Copy link

xerdnew commented Aug 13, 2023

@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
Copy link

new version work well.

@timhatch
Copy link

@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
Copy link

sultanularefin commented Aug 21, 2023

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
Copy link

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

@ManeeshNadcab
Copy link

i was getting same error.

@tuiza
Copy link

tuiza commented Dec 22, 2023

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

@Vimal1464
Copy link

@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
Copy link

krmahil commented Jan 12, 2024

@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
Copy link

@krmahil Welcome

@benjanknoetze
Copy link

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

@ergen35
Copy link

ergen35 commented Apr 30, 2024

@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
Copy link

Vimal1464 commented May 2, 2024

@ergen35 Welcome, Happy to help

@yasithg
Copy link

yasithg commented Feb 21, 2025

// forces Gradle to run copyReactNativeVectorIconFonts before lintAnalyzeDebug
afterEvaluate {
    tasks.matching { it.name == "lintAnalyzeDebug" }.all {
        it.dependsOn tasks.matching { task -> task.name == "copyReactNativeVectorIconFonts" }
    }
}

Add this end of android/app/build.gradle fixed the issue for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests