Skip to content
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

Build error - A problem was found with the configuration of task ':app:lintAnalyzeDebug' #1588

Open
leonardo-coutinho-dev opened this issue Jan 5, 2024 · 5 comments

Comments

@leonardo-coutinho-dev
Copy link

leonardo-coutinho-dev commented Jan 5, 2024

Hey guys, I am facing an issue when trying to build a project with ./gradlew build, on the android folder!

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:\Projetos\hph-services-app\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.

I was trying to build on windows

------------------------------------------------------------
Gradle 8.0.1
------------------------------------------------------------

Build time:   2023-02-17 20:09:48 UTC
Revision:     68959bf76cef4d28c678f2e2085ee84e8647b77a

Kotlin:       1.8.10
Groovy:       3.0.13
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          11.0.2 (Oracle Corporation 11.0.2+9)
OS:           Windows 10 10.0 amd64
"react-native-vector-icons": "^10.0.2",
"react-native": "0.72.6",

I saw some solutions here:

#1508

Solution:

Adding the following lines to node_modules/react-native-vector-icons/fonts.gradle

/**
 * Register font asset source folder
 */
android.sourceSets.main.assets.srcDirs += file("$buildDir/intermediates/ReactNativeVectorIcons")

/**
 * 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 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)

        def lintVitalAnalyzeTask = tasks.findByName("lintVitalAnalyze${targetName}")
        lintVitalAnalyzeTask?.dependsOn(fontCopyTask)

        // add this: --------------------->
        def lintAnalyzeTask = tasks.findByName("lintAnalyze${targetName}")
        lintAnalyzeTask?.dependsOn(fontCopyTask)
    }
}

Check the two lines after // add this: --------------------->

@oblador

The error is similar to #1508 but this time with task lintAnalyzeTask

@lanedirt
Copy link

@leonardo-coutinho-dev Thanks for this fix! I was experiencing the same error after upgrading from react native 0.71.3 to 0.73.2 and the proposed solution fixes the build for me.

@Czakero
Copy link

Czakero commented Feb 12, 2024

I had same issues followed by another ones, I had to add 3 new dependency configurations (cheaper and faster solution is to downgrade gradle as of some version it requires explicit/implicit dependency between tasks declarations, there is a probability where other tools and tasks will give similar problems in the future):

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")
    if (generateAssetsTask) {
        generateAssetsTask.dependsOn(fontCopyTask)
    }

///// New declarations

    def generateReportModelTask = tasks.findByName("generate${targetName}LintReportModel")
    if (generateReportModelTask) {
        generateReportModelTask.dependsOn(fontCopyTask)
    }

    def lintAnalyzeDebugTask = tasks.findByName("lintAnalyze${targetName}")
    if (lintAnalyzeDebugTask) {
        lintAnalyzeDebugTask.dependsOn(fontCopyTask)
    }

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

EDIT: There is a second way of disabling lint in build totally by building android project with gradle command

./gradlew clean build -x lint -x lintVitalAnalyzeDebug -x lintVitalAnalyzeRelease

And by appending some configuration in android/app/build.gradle file (under android tag):

lintOptions { checkReleaseBuilds false }

My project package configuration:

`
I'm using gradle version 8.5

"dependencies": {
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"@rneui/themed": "^4.0.0-rc.8",
"metro-react-native-babel-transformer": "^0.77.0",
"node-sass": "^9.0.0",
"react": "18.2.0",
"react-native": "0.73.2",
"react-native-keychain": "^8.1.2",
"react-native-maps": "^1.10.2",
"react-native-safe-area-context": "^4.8.2",
"react-native-sass-transformer": "^2.0.0",
"react-native-screens": "^3.29.0",
"react-native-vector-icons": "^10.0.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/babel-preset": "0.73.19",
"@react-native/eslint-config": "0.73.2",
"@react-native/metro-config": "0.73.3",
"@react-native/typescript-config": "0.73.1",
"@types/react": "^18.2.6",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.6.3",
"eslint": "^8.19.0",
"jest": "^29.6.3",
"prettier": "2.8.8",
"react-test-renderer": "18.2.0",
"typescript": "5.0.4"
},
"engines": {
"node": ">=18"
}
}
`

I'm thinking about dropping apply of fonts.gradle from app/build.gradle and making my own copy method for assets, will see how it works and how long it will take for dev's here to fix the issue with some more generic solution rather than configuring each task dependencies.

@benjanknoetze
Copy link

The same issue here on RN 0.72.4
There is a PR that I believe will solve this here.
Can we not have it merged in, please?

@ckswopnera
Copy link

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)

@sheirla
Copy link

sheirla commented Apr 27, 2024

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)

thank you so much, its work perfectly

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

6 participants