user9737826
user9737826

Reputation:

BVLinearGradient was not found in the UIManager?

There is documentation about this, but it is for macOs only. https://github.com/react-native-community/react-native-linear-gradient.

I linked the library by running npm install react-native link react-native-linear-gradient.

I don't understand this i dont have a ios folder, i installed pod but my ios folder remained empty:

iOS For React Native >= 0.60.0 run the following command in the ios/ folder and skip the rest of the section.

pod install CocoaPods Add the following line to your Podfile:

pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient' or:

This below is only for macOs ?

Manually Open your project in Xcode, right click on Libraries and click Add Files to "Your Project Name" Look under node_modules/react-native-linear-gradient/ios and add BVLinearGradient.xcodeproj. (Screenshot 1) (Screenshot 2). Add libBVLinearGradient.a to Build Phases -> Link Binary With Libraries (Screenshot 1) (Screenshot 2). Click on BVLinearGradient.xcodeproj in Libraries and go the Build Settings tab. Double click the text to the right of Header Search Paths and verify that it has $(SRCROOT)/../react-native/React - if it isn't, then add it. This is so Xcode is able to find the headers that the BVLinearGradient source files are referring to by pointing to the header files installed within the react-native node_modules directory. (Screenshot).

How to do it in Windows and i don't have an ios map inside node_modules/react-native-linear-gradient/?

how can I make it work?

Upvotes: 23

Views: 61384

Answers (18)

Chaman Khan
Chaman Khan

Reputation: 81

This was error when I just installed react-native-linear-gradient by library [docs] and write that code...

After this error, I just clean app by ./android./gradlew clean

and after that I restart the app and it works correctly

Upvotes: 1

Jerry Azubuike
Jerry Azubuike

Reputation: 1

This error occurs as a result of package not yet installed in pod, go to project folder then

cd iOS pod install

Upvotes: 0

Muhammad Ibrahim
Muhammad Ibrahim

Reputation: 321

jz an additional info for those android user:

  1. clean ur gradle: cd android && ./gradlew clean
  2. reinstall ur node modules: cd .. && rm -rf node_modules && npm i
  3. start again with fresh cache: npm start -- --reset-cache

for me theese step fixed this issue

reference

Upvotes: 1

Fravel
Fravel

Reputation: 187

I was also getting this error as soon as I added the component to a view.

To get rid of the error, I went to the /ios folder and ran pod install. As indicated in the README of the package.

If your pod install does not work, ensure that cacaopods is installed and that you have the last ruby version.

Upvotes: 0

Arthur_ko
Arthur_ko

Reputation: 21

  • Step 1 - npm install expo-linear-gradient
  • Step 2 - import { LinearGradient } from expo-linear-gradient

Upvotes: 2

Himanshu Agrawal
Himanshu Agrawal

Reputation: 106

Check whether these two lines are in your 'package file'.

'React', :path => '../node_modules/react-native'

'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'

If yes then --

Run "pod install" under $project path/ios before react-native run-ios.

Upvotes: 9

Collins Olix
Collins Olix

Reputation: 91

Ensure you are using the package from expo if you are running an expo build!

I experienced similar issue because I was migrating from a React-Native managed app to an expo build, so the react-native-linear-gradient package from React-Native didn't work even after killing and restarting the app. It turned out I had to use the expo-linear-gradient package instead.

Upvotes: 0

Parsa Yazdani
Parsa Yazdani

Reputation: 348

For Expo users, running npx expo prebuild fixed it for me. And make sure you rebuild your app again. Here's the prebuild commands based on your platform:

IOS:

npx expo prebuild --platform ios && npx expo run:ios

Android:

npx expo prebuild --platform android && npx expo run:android

Upvotes: 1

Prashant Jaiswal
Prashant Jaiswal

Reputation: 21

Simple use a expo command.

  • npm install expo-linear-gradient

Use this on the page

  • import { LinearGradient } from "expo-linear-gradient";

Upvotes: 2

sahba
sahba

Reputation: 39

  • cd iOS
  • bundle install
  • bundle exec pod install

Upvotes: 0

Warren
Warren

Reputation: 2044

Android

If you are on android, simply do the native rebuild again with:

yarn android

or

npm run android

Upvotes: 2

Shayan Sheshashayan
Shayan Sheshashayan

Reputation: 109

I had similar issue with Android. Solution: Kill the app and relaunch this should solve the problem

Upvotes: 10

Harsha Sandakelum
Harsha Sandakelum

Reputation: 21

Easy Way..! Try This..!

  1. Run this code in Terminal window

    expo install expo-linear-gradient

  2. Use this code to import the LinearGradient

    import { LinearGradient } from "expo-linear-gradient";

Upvotes: 2

Salwa A. Soliman
Salwa A. Soliman

Reputation: 746

if you're using windows & react-native cli (not expo):

1- in android/settings.gradle, check if

include ':react-native-linear-gradient' project(':react-native-linear-gradient').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-linear-gradient/android')

exist .. if not, add them


2- in android/app/build.gradle, check if

implementation project(':react-native-linear-gradient')

exists in dependecies{ ... } .. if not, add it


3- in android/app/src/main/java/com/{YOUR_APP_NAME}/MainApplication.java , find

@Override protected List getPackages() { ....}

Then replace the comment // packages.add(new MyReactNativePackage());

with => packages.add(new LinearGradientPackage());

Upvotes: 2

Sachin Saini
Sachin Saini

Reputation: 401

First, install the https://github.com/react-native-community/react-native-linear-gradient library.

then go to the cd ios and run

cd ios
pod install

now use go back using cd ..

and run (optional )

 react-native link react-native-linear-gradient

now run

react-native run-ios

Upvotes: 1

bitbuoy
bitbuoy

Reputation: 393

If using expo and this error is thrown after installing react-native-linear-gradient follow along.

error ? the expo framework still does not have "sight" of the linear gradient package .

solution ? Run the command "expo install expo-linear-gradient" from your root folder, go to the file that you had previously imported the linear gradient as "import LinearGradient from 'react-native-linear-gradient" and change the line to "import {LinerGradient} from 'expo-linear-gradient'".

Restart your server, "expo start". PS: This solution is only applicable for react-native projects being built using expo

Upvotes: 0

Yazan Najjar
Yazan Najjar

Reputation: 2206

Simply you just need to go to ios folder

cd ios
pod install

That's it

Upvotes: 1

Indika_Nuwan95
Indika_Nuwan95

Reputation: 679

use this one if you are using expo

1 . paste this in terminal window :

expo install expo-linear-gradient

2.add the import statement to the file :

import {LinearGradient} from 'expo-linear-gradient';

worked for me !

Upvotes: 57

Related Questions