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

"RNCViewPager" was not found in the UIManager. [RN 0.61.2] [Android] #72

Closed
mistikk opened this issue Oct 10, 2019 · 29 comments
Closed
Labels
Resolution: Needs Repro This issue could be improved with a demo to reproduce the issue.

Comments

@mistikk
Copy link

mistikk commented Oct 10, 2019

Bug

image

Environment info

react-native: 0.61.2
react-native-viewpager: 2.0.1

@ferrannp
Copy link
Contributor

For what I see you are using https://github.com/ptomasroos/react-native-scrollable-tab-view. See https://github.com/ptomasroos/react-native-scrollable-tab-view/blob/master/index.js#L13. ViewPagerAndroid is not part of react-native core anymore. You should open an issue to that repo and ask to update the library to use https://github.com/react-native-community/react-native-viewpager instead.

@mistikk
Copy link
Author

mistikk commented Oct 10, 2019

@ferrannp I am not using ptomasroos/react-native-scrollable-tab-view. I forked and updated with react-native-community/react-native-viewpager.
You can see forked repo https://github.com/esteemapp/react-native-scrollable-tab-view

@ferrannp
Copy link
Contributor

If you create a new app with react-native init, does the viewpager here works for you?

@ferrannp ferrannp reopened this Oct 10, 2019
@baleo-it
Copy link

baleo-it commented Oct 17, 2019

@mistikk RN > 0.60, you need to do

cd ios
pod install --repo-update

@mistikk
Copy link
Author

mistikk commented Oct 18, 2019

@baleo-it i already run pod install

@ferrannp ferrannp added the Resolution: Needs Repro This issue could be improved with a demo to reproduce the issue. label Oct 18, 2019
@ferrannp
Copy link
Contributor

Can you provide a repository to reproduce your issue?

@superandrew213
Copy link

@ferrannp here is the repo https://github.com/superandrew213/viewpagertest.

This uses the latest version of react-native-scrollable-tab-view from github which uses @react-native-community/viewpager

https://github.com/ptomasroos/react-native-scrollable-tab-view/commits/master

@ferrannp
Copy link
Contributor

@superandrew213 if you install @react-native-community/viewpager it works. I think the problem is in https://github.com/ptomasroos/react-native-scrollable-tab-view/blob/master/package.json#L27-L29. Can you try and add @react-native-community/viewpager as peerDependency ?

@superandrew213
Copy link

@ferrannp I can confirm that it works if you install @react-native-community/viewpager.

@react-native-community/viewpager has been added as a dependency to react-native-scrollable-tab-view. Why add it as a peer dependency?

@ferrannp
Copy link
Contributor

Ok maybe you just have to document it. The same as with react-navigation, that is documented you need to install react-native-gesture-handler, react-native-reanimated with it.

@superandrew213
Copy link

@ferrannp @react-native-community/viewpager should be working even if it has been added as a dependency. This is probably a linking issue?

@Domtry
Copy link

Domtry commented Nov 14, 2019

Any solution proposal did not solve my problem

this is my package.js config

"dependencies": {
"react": "16.9.0",
"react-native": "0.61.4",
"react-native-elements": "^1.2.7",
"react-native-input-scroll-view": "^1.9.5",
"react-native-navigation": "^3.5.1",
"react-native-scrollable-tab-view": "^1.0.0",
"react-native-vector-icons": "^6.6.0"
},
"devDependencies": {
"@babel/core": "7.7.2",
"@babel/runtime": "7.7.2",
"@react-native-community/eslint-config": "0.0.5",
"babel-jest": "24.9.0",
"jest": "24.9.0",
"metro-react-native-babel-preset": "0.56.3",
"react-test-renderer": "16.9.0"
},
"jest": {
"preset": "react-native"
}
}

@jakajacky
Copy link

i have the same error, RN = 0.60.5, Platform = iOS/Android
And fixed by Manual linking guide, both iOS,Android work fine.

  1. npm i @react-native-community/viewpager
  2. on iOS, adding this to your Podfile:
    pod 'react-native-viewpager', :path => '../node_modules/@react-native-community/viewpager'
    then
    cd ios
    pod install
  3. on Android, make the following changes:

android/settings.gradle

include ':@react-native-community_viewpager'
project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android')

android/app/build.gradle

dependencies {
   ...
   implementation project(':@react-native-community_viewpager')
}

android/app/src/main/.../MainApplication.java

On top, where imports are:

import com.reactnativecommunity.viewpager.RNCViewPagerPackage;

Add the RNCViewPagerPackage class to your list of exported packages.

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new RNCViewPagerPackage()
  );

@igorbrandao
Copy link

Any solution for those using a non ejected expo app?

@sytolk
Copy link

sytolk commented Feb 19, 2020

I have the same issue on Android (iOS works) RN 0.60.6
dependencies:
"react-native-best-viewpager": "^1.0.4", -> https://github.com/abbasmoosavi/react-native-best-viewpager/blob/master/package.json#L39
"@react-native-community/viewpager": "^3.3.0", <- adding this line in my project package.json fix this issue
Maybe this issue is yarn related ??

@claezon
Copy link

claezon commented Feb 28, 2020

This worked for me:

RN-cli: 2.0.1
RN: 0.61.5

I tried linking the package, but that didn't help.
I tried manual linking and saw that the RNCViewPagerPackage was missing in:
android/app/src/main/java/com/[...]/MainApplication.java

I added the package (last line before return):
@Override protected List<ReactPackage> getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List<ReactPackage> packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new MyReactNativePackage()); packages.add(new RNCViewPagerPackage()); // <--------- Here we go return packages; }

I emptied cache and ran: react-native run-android.

@UnnikrishnanBhargavakurup
Copy link

Still facing the same issue in android any idea how to fix this?

@olkunmustafa
Copy link

i have the same error, RN = 0.60.5, Platform = iOS/Android
And fixed by Manual linking guide, both iOS,Android work fine.

  1. npm i @react-native-community/viewpager
  2. on iOS, adding this to your Podfile:
    pod 'react-native-viewpager', :path => '../node_modules/@react-native-community/viewpager'
    then
    cd ios
    pod install
  3. on Android, make the following changes:

android/settings.gradle

include ':@react-native-community_viewpager'
project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android')

android/app/build.gradle

dependencies {
   ...
   implementation project(':@react-native-community_viewpager')
}

android/app/src/main/.../MainApplication.java

On top, where imports are:

import com.reactnativecommunity.viewpager.RNCViewPagerPackage;

Add the RNCViewPagerPackage class to your list of exported packages.

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new RNCViewPagerPackage()
  );

It is the solution.

@tiagobbraga
Copy link

Modification in the last step using with RN 0.63.2 and React 16.13.1

Instead of

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new RNCViewPagerPackage()
  );

this

protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          packages.add(new RNCViewPagerPackage());
          return packages;
        }

i have the same error, RN = 0.60.5, Platform = iOS/Android
And fixed by Manual linking guide, both iOS,Android work fine.

  1. npm i @react-native-community/viewpager
  2. on iOS, adding this to your Podfile:
    pod 'react-native-viewpager', :path => '../node_modules/@react-native-community/viewpager'
    then
    cd ios
    pod install
  3. on Android, make the following changes:

android/settings.gradle

include ':@react-native-community_viewpager'
project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android')

android/app/build.gradle

dependencies {
   ...
   implementation project(':@react-native-community_viewpager')
}

android/app/src/main/.../MainApplication.java

On top, where imports are:

import com.reactnativecommunity.viewpager.RNCViewPagerPackage;

Add the RNCViewPagerPackage class to your list of exported packages.

@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new RNCViewPagerPackage()
  );

@biomancer
Copy link

biomancer commented May 28, 2021

In my case just adding @react-native-community/viewpager explicitly to dependencies in package.json of my project solved the issue, no manual linking was required after that (RN 0.64.0), same as #72 (comment)

@kevinblu
Copy link

kevinblu commented Jun 3, 2021

new RNCViewPagerPackage()

It really worked!!!!!! Thank you 3000!

Little tips: if you use DefaultHardwareBackBtnHandler interface to init your reactActivity, you might need to add RNCViewPagerPackage like this
mReactInstanceManager = ReactInstanceManager.builder() .setApplication(getActivity().getApplication()) ......... .addPackage(new RNCViewPagerPackage()) ....... .build();

@troZee
Copy link
Member

troZee commented Jun 21, 2021

yarn add @react-native-community/viewpager
react-native link @react-native-community/viewpager

This worked for me. React Native version 0.64.2

You are using wrong package name. Please use this commend yarn add react-native-pager-view. You don't need to link this library, bc cli has autolinking module.

@bracketsberlin
Copy link

bracketsberlin commented Sep 8, 2021

I have the same issue under Android RN 0.64.2.

I am using the component and just migrated to 3.1.1. Once I try displaying the component, I'm getting the following error message:
"RNCViewPager" was not found in the UIManager.

My package.json lists the following packages:

"react-native-pager-view": "^5.4.1",
"react-native-tab-view": "^3.1.1",

As suggested by @troZee , I ran:

yarn add react-native-pager-view
react-native link react-native-pager-view

I'd love to get some pointers - I just can't make it work!

@hpardess
Copy link

hpardess commented Dec 20, 2021

I have the same issue while running my app in Android emulator.
Screen Shot 2021-12-20 at 10 29 20 PM

ERROR  Invariant Violation: requireNativeComponent: "RNCViewPager" was not found in the UIManager.
This error is located at:
    in RNCViewPager (at PagerView.tsx:145)
    in PagerView (at createAnimatedComponent.js:242)
    in AnimatedComponent (at createAnimatedComponent.js:295)
    in AnimatedComponentWrapper (at PagerViewAdapter.tsx:123)
    in PagerViewAdapter (at TabView.tsx:79)
    in RCTView (at View.js:32)
    in View (at TabView.tsx:78)

Here is my project dependencies:
"react": "17.0.2",
"react-native": "0.66.4",
"react-native-tab-view": "^3.1.1",

@maxizhukov
Copy link

Same issue in ios RN 64.1

@Furqan02
Copy link

run : npm i react-native-pager-view

@scottmas
Copy link

Make sure you do pod install and then a full native rebuild after installing react-native-pager-view since it has native dependencies

@omarbakr2020
Copy link

This is my solution for this issue, You can check it out

https://stackoverflow.com/a/75277939/10504018

@moin-nimblechapps
Copy link

Same issue in RN: 73.4

@react-navigation/native-stack": "^6.9.18",
react-navigation/material-top-tabs": "^6.6.12"
"react-native-pager-view": "^6.2.3"
"react-native-tab-view": "^3.5.2"

please help to solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Needs Repro This issue could be improved with a demo to reproduce the issue.
Projects
None yet
Development

No branches or pull requests