3

I have installed React Native Vector Icons, but it fails on build when i run "react-native run-android", with this error:

startup failed: build file 'C:\projects\musicapp\android\app\build.gradle': 3: unexpected token: apply @ line 3, column 1. apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" ^

Misterwyz
  • 101
  • 1
  • 2
  • 6

2 Answers2

12

Installation:

npm install --save react-native-vector-icons

For Automatic link (RN < 0.60)

react-native link react-native-vector-icons

For Manual setup

Edit android/app/build.gradle ( NOT android/build.gradle ) and add the following:

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Run the project to test the installation.

react-native run-android

Import the library.

import Icon from ‘react-native-vector-icons/FontAwesome’

Use it inside JSX. Text styles are welcome to be applied. Below is an example using also separated grid.* styling file.

<View>
   <Icon name='area-chart' color="green" size={20} />
   <Text>Enjoy Coding.</Text>
</View>
Aniruddha Shevle
  • 4,602
  • 4
  • 22
  • 36
Dinesh Katwal
  • 930
  • 1
  • 14
  • 25
0

react-native >=0.60

step:1 yarn add react-native-vector-icons

step:2 Add apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" in (android/app/build.gradle)

step:3 cd android in cmd

step:4 ./gredlew clean

step:5 react-native run-android

step:6 import Icon from ‘react-native-vector-icons/FontAwesome’

surya raghul
  • 77
  • 1
  • 2