oblador / react-native-vector-icons

Customizable Icons for React Native with support for image source and full styling.
https://oblador.github.io/react-native-vector-icons/
MIT License
17.31k stars 2.12k forks source link

Android: Release build fails with React Native 0.72.6 #1564

Closed andreirat closed 1 month ago

andreirat commented 8 months ago

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.

BUILD FAILED in 23m 57s

Any idea why is this happening?

mgvictor7 commented 8 months ago

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

beary commented 8 months ago

Thanks for @VincentSastra providing the solution here: https://github.com/oblador/react-native-vector-icons/issues/1508#issuecomment-1664993744

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 commented 7 months ago

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?

mauricioalexandres commented 5 months ago

Do you found any solution?

johnf commented 1 month ago

Closing as this should be fixed in the latest release