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

Android: Release build fails with React Native 0.72.6 #1564

Closed
andreirat opened this issue Oct 27, 2023 · 5 comments
Closed

Android: Release build fails with React Native 0.72.6 #1564

andreirat opened this issue Oct 27, 2023 · 5 comments
Labels
waiting Waiting on OP response

Comments

@andreirat
Copy link

Environment

Android
react-native: 0.72.6
react-native-vector-icons: ^10.0.1

Description

While building the app in AppCenter, the build fails with the following message:

FAILURE: Build failed with an exception.

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

    • Gradle detected a problem with the following location: '/Users/runner/work/1/s/android/app/build/intermediates/ReactNativeVectorIcons'.

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

      Please refer to https://docs.gradle.org/8.0.1/***guide/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 23m 57s

Any idea why is this happening?

@mgvictor7
Copy link

I found this possible solution on https://stackoverflow.com/a/76658738

@beary
Copy link

beary commented Nov 3, 2023

Thanks for @VincentSastra providing the solution here: #1508 (comment)

And I created a post-install script to automate this, here is my code

/* package.json */
...
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest",
+   "postinstall": "node scripts/react-native-vector-icons.mjs"
  },
...
/* scripts/react-native-vector-icons.mjs */

import { readFileSync, writeFileSync } from 'node:fs'
import { resolve } from 'node:path'

const fontGradlePath = resolve('node_modules/react-native-vector-icons/fonts.gradle')
const fontGradle = readFileSync(fontGradlePath, { encoding: 'utf-8' })

const appendTask = `
def lintAnalyzeTask = tasks.findByName("lintAnalyze\${targetName}")
lintAnalyzeTask?.dependsOn(fontCopyTask)
`
const dependsOnStr = '.dependsOn(fontCopyTask)'
const firstLine = appendTask.split('\n').filter((it) => it)[0]

if (!fontGradle.includes(firstLine)) {
  const insertPosition =
    fontGradle.lastIndexOf(dependsOnStr) + dependsOnStr.length
  const newfontGradle = [
    fontGradle.slice(0, insertPosition),
    appendTask,
    fontGradle.slice(insertPosition)
  ].join('\n')
  writeFileSync(fontGradlePath, newfontGradle, { encoding: 'utf-8' })
}

@johnf
Copy link
Collaborator

johnf commented Nov 7, 2023

I suspect this is related to #1534

I'd like to put this to bed once and for all, but I'm not experiencing this my project using RNVI on android.

Is someone able to provide a reproducible example repository?

@johnf johnf added the waiting Waiting on OP response label Nov 7, 2023
@mauricioalexandres
Copy link

Do you found any solution?

@johnf
Copy link
Collaborator

johnf commented May 21, 2024

Closing as this should be fixed in the latest release

@johnf johnf closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting on OP response
Projects
None yet
Development

No branches or pull requests

5 participants