React Native Vector Icons导致构建错误。

huangapple go评论76阅读模式
英文:

React Native Vector Icons causing build error

问题

I created a React Native Project and Worked on it, It works perfect on debug build. But when I run ./gradlew assembleRelease inside android directory, It leads me to an error.

> Task :app:copyReactNativeVectorIconFonts FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':app:copyReactNativeVectorIconFonts' (type 'Copy').
  - Gradle detected a problem with the following location: '/Projects/AppName/android/app/build/intermediates/ReactNativeVectorIcons/fonts'.
    
    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.

* Get more help at https://help.gradle.org

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 4s
214 actionable tasks: 7 executed, 207 up-to-date

Here's package.json

{
  "name": "App Name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-async-storage/async-storage": "^1.19.0",
    "@react-navigation/bottom-tabs": "^6.5.8",
    "@react-navigation/native": "^6.1.7",
    "@react-navigation/native-stack": "^6.9.13",
    "@reduxjs/toolkit": "^1.9.5",
    "axios": "^1.4.0",
    "react": "18.2.0",
    "react-native": "0.72.1",
    "react-native-linear-gradient": "^2.7.3",
    "react-native-safe-area-context": "^4.6.3",
    "react-native-screens": "^3.22.0",
    "react-native-splash-screen": "^3.3.0",
    "react-native-vector-icons": "^9.2.0",
    "react-redux": "^8.1.1"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.7",
    "@tsconfig/react-native": "^3.0.0",
    "@types/metro-config": "^0.76.3",
    "@types/react": "^18.0.24",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.2.1",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.76.5",
    "prettier": "^2.4.1",
    "react-native-dotenv": "^3.4.9",
    "react-test-renderer": "18.2.0",
    "typescript": "4.8.4"
  },
  "engines": {
    "node": ">=16"
  }
}

I created this project with npx react-native init AppName.

I'm on macOS Ventura 13.4.1

NodeJS - 18.15.0
Yarn - 1.22.19

Android Studio Electric Eel | 2022.1.1 Patch 2 --
Build #AI-221.6008.13.2211.9619390, built on February 17, 

<details>
<summary>英文:</summary>

I created a React Native Project and Worked on it, It works perfect on debug build. But when I run `./gradlew assembleRelease` inside `android` directory, It leads me to an error.

> Task :app:copyReactNativeVectorIconFonts FAILED

FAILURE: Build failed with an exception.

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

    • Gradle detected a problem with the following location: '/Projects/AppName/android/app/build/intermediates/ReactNativeVectorIcons/fonts'.

      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.

  • Get more help at https://help.gradle.org

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 4s
214 actionable tasks: 7 executed, 207 up-to-date


Here&#39;s `package.json`

{
"name": "App Name",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-native-async-storage/async-storage": "^1.19.0",
"@react-navigation/bottom-tabs": "^6.5.8",
"@react-navigation/native": "^6.1.7",
"@react-navigation/native-stack": "^6.9.13",
"@reduxjs/toolkit": "^1.9.5",
"axios": "^1.4.0",
"react": "18.2.0",
"react-native": "0.72.1",
"react-native-linear-gradient": "^2.7.3",
"react-native-safe-area-context": "^4.6.3",
"react-native-screens": "^3.22.0",
"react-native-splash-screen": "^3.3.0",
"react-native-vector-icons": "^9.2.0",
"react-redux": "^8.1.1"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.7",
"@tsconfig/react-native": "^3.0.0",
"@types/metro-config": "^0.76.3",
"@types/react": "^18.0.24",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.76.5",
"prettier": "^2.4.1",
"react-native-dotenv": "^3.4.9",
"react-test-renderer": "18.2.0",
"typescript": "4.8.4"
},
"engines": {
"node": ">=16"
}
}


I created this project with `npx react-native init AppName`.

I&#39;m on macOS Ventura 13.4.1

NodeJS - 18.15.0
Yarn - 1.22.19

Android Studio Electric Eel | 2022.1.1 Patch 2 --
Build #AI-221.6008.13.2211.9619390, built on February 17, 2023

java version "17.0.6" 2023-01-17 LTS
Java(TM) SE Runtime Environment (build 17.0.6+9-LTS-190)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.6+9-LTS-190, mixed mode, sharing)



</details>


# 答案1
**得分**: 1

请检查这个链接。它帮助了我,也许你也可以尝试一下。

https://github.com/oblador/react-native-vector-icons/issues/1508

<details>
<summary>英文:</summary>

Please check this. It helped me. Maybe you can try it too.

https://github.com/oblador/react-native-vector-icons/issues/1508

</details>



huangapple
  • 本文由 发表于 2023年7月3日 22:29:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605709.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定