Skip to content

Android: Invariant Violation requireNativeComponent: "RNCViewPager" was ton found in the UIManager #1050

Open

Description

@zmnv

I've just update react-native-scrollable-tab-view to 1.0.0 by yarn. But still have error.

Steps to Reproduce

yarn add react-native-scrollable-tab-view@1.0.0
import ScrollableTabView, { ScrollableTabBar } from 'react-native-scrollable-tab-view';
....
<ScrollableTabView
    style={{ marginTop: 0, marginBottom: 10, height: 50, flex: 0 }}
    onChangeTab={this...}
    initialPage={0}
    renderTabBar={() => (
        <ScrollableTabBar
            activeTextColor="..."
            inactiveTextColor="..."
            style={{
                ...
            }}
            tabsContainerStyle={{
                ...
            }}
            underlineStyle={{
                height: 2,
            ...
            }}
            tabStyle={{
                ...
            }}
            textStyle={{ fontSize: 12, fontWeight: 'normal' }}
        />
    )}
>
    {metrics.map(metricName => (
        <View
            key={metricName}
            tabLabel={metricName}
        >
            <Text>{metricName}</Text>
        </View>
    ))}
</ScrollableTabView>

Expected Behavior

Should work because I setup latest version of module. And in yarn.lock:

image

also ViewPager there is in node_modules:

Actual Behavior

Android

iOS
All fine.

I've try

  • Clean yarn cache
  • Clean react native & metro cache
  • rm -rf node_modules
  • delete build folders

Activity

  1. zmnv commented on Oct 29, 2019

    @zmnv
    Author

    I look at:
    /node_modules/react-native-scrollable-tab-view/index.js

    Why do you use Animated.ScrollView for iOS and AnimatedViewPagerAndroid for Android? Can you use Animated.ScrollView for all?

    also there are definitions which don't used

  2. zmnv commented on Oct 29, 2019

    @zmnv
    Author

    temporary solution is just:

    yarn add @react-native-community/viewpager
    

    but I don't want to install that module direct into project :(

  3. ptomasroos commented on Oct 29, 2019

    @ptomasroos
    Owner

    I would love to have a PR on a scroll based solution of android. It’s there for historical reasons.

  4. haack commented on Oct 31, 2019

    @haack

    I have the same issue on Android. Manually adding @react-native-community/viewpager didn't solve the problem for me.

  5. zunsakai commented on Oct 31, 2019

    @zunsakai

    same issue ...

  6. cereme commented on Nov 2, 2019

    @cereme

    I have same issue too

  7. vetrivendhan48 commented on Nov 4, 2019

    @vetrivendhan48

    temporary solution is just:

    yarn add @react-native-community/viewpager
    

    but I don't want to install that module direct into project :(

    I guess there will be no issue in doing that I guess. npm will manage dependencies right? Is there will be any issue will come if you modify its dependencies? Please let me know.
    Thanks

  8. zmnv commented on Nov 4, 2019

    @zmnv
    Author

    @vetrivendhan48 not a big deal actually, but.

    But when you search in project directory @react-native-community/viewpager it's returns nothing. Then other developers thinks like 'oh, that dependency is not used in project so it unnecessary, I can delete it!'.

    And build fails next time)))))))

    also guys above says that solution didn't work. I don't know why. In my case it works.

  9. azamouchi commented on Nov 6, 2019

    @azamouchi

    yarn add @react-native-community/viewpager on it's own does not solve the issue, you need to link the package also using react-native link @react-native-community/viewpager

  10. w13808604 commented on Nov 8, 2019

    @w13808604

    same issue ..anybody solve it

  11. chenyanfei-m commented on Nov 8, 2019

    @chenyanfei-m

    yarn add @react-native-community/viewpager
    react-native link @react-native-community/viewpager
    and rebuild, solve it ✨

  12. mastahed commented on Nov 12, 2019

    @mastahed

    Any fix for expo 35 with RN 0.59? works well on IOS, android shows the same error. Tried link and manual installation of viewpager.

  13. kaiyes commented on Nov 18, 2019

    @kaiyes

    yarn add @react-native-community/viewpager
    react-native link @react-native-community/viewpager
    and rebuild and solve it

    This worked for me

  14. xgAnd commented on Nov 18, 2019

    @xgAnd

    yarn add @react-native-community/viewpager
    react-native link @react-native-community/viewpager
    and rebuild and solve it

    worked react-native version is 0.61.3

  15. winseyli commented on Nov 28, 2019

    @winseyli

    yarn add @react-native-community/viewpager
    react-native link @react-native-community/viewpager
    and rebuild, solve it ✨

    Thank you this works for me too. RN 0.61.4
    (Seems like it is not necessary to link the package if there is autolinking for >=0.60)

  16. 15 remaining items

  17. nabilfreeman commented on May 4, 2020

    @nabilfreeman

    Hi, I just ran npm install --save @react-native-community/viewpager and it autolinked.

    I also made sure that my react-native-scrollable-tab-view version is the latest commit on master (not npm).

    "@react-native-community/viewpager": "4.0.0",
    "react-native-scrollable-tab-view": "github:ptomasroos/react-native-scrollable-tab-view#510111adce035a54ecb1b5f77b78e3bfaf513260",
    

    To confirm... no manual steps required!! 🎉

    Edit: I spoke too soon, this breaks iOS so I had to add this to my postinstall script:

    RN_VIEWPAGER_FILE="./node_modules/@react-native-community/viewpager/react-native-viewpager.podspec"
    
    if [ -e $RN_VIEWPAGER_FILE ]; then
    	echo "Patching @react-native-community/viewpager to not autolink (we only want this peer dep on Android)"
    	rm -rf $RN_VIEWPAGER_FILE
    fi
    

    So now...

    1. react-native-scrollable-tab-view adds @react-native-community/viewpager@3.3
    2. @react-native-community/viewpager@4 installed from package.json
    3. viewpager 4 autolinks to Android, not to iOS

    Everything works.

    I think the ideal would be to remove viewpager as a dep from this library and instead have it as a required peer dependency.

  18. nabilfreeman commented on May 5, 2020

    @nabilfreeman

    Last update... I downgraded my version of @react-native-community/viewpager to 3.3 (matches the master branch of this repo) and now everything is playing nicely. Removed the postinstall steps above.

  19. deot commented on May 21, 2020

    @deot

    package.json

    "resolutions": {
        "@react-native-community/viewpager": "^4.0.0"
    },
    

    Android > 60.0, check file:
    android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java

      public ArrayList<ReactPackage> getPackages() {
        return new ArrayList<>(Arrays.<ReactPackage>asList(
          // ...
          new RNCViewPagerPackage()
        ));
      }
    

    link

  20. simo-hsieh commented on Jun 22, 2020

    @simo-hsieh

    This worked for me.

    This issue is caused by the wrong dependency version,
    and it's fixed in the commit 510111adce035a54ecb1b5f77b78e3bfaf513260,
    but not officially released.
    To install the specific commit version instead of the official released one, run

    RN v0.61

    yarn add react-native-scrollable-tab-view@https://github.com/ptomasroos/react-native-scrollable-tab-view#510111adce035a54ecb1b5f77b78e3bfaf513260
    

    RN v0.62

    yarn add react-native-scrollable-tab-view@https://github.com/ptomasroos/react-native-scrollable-tab-view#1371236e91c217e2f42468e355419f83410e3133
    
  21. heyixing commented on Jul 22, 2020

    @heyixing

    yarn add @react-native-community/viewpager
    react-native link @react-native-community/viewpager
    and rebuild and solve it

    This worked for me

    it's also worked for me ,thanks!

  22. bobananto24 commented on Feb 12, 2021

    @bobananto24

    I have the same issue on Android. Manually adding @react-native-community/viewpager didn't solve the problem for me.

    run the command "react-native run-android" or "react-native run-ios" instead of "react-native start"

  23. hungdev commented on Mar 6, 2021

    @hungdev

    installed viewpager, works for me, thanks @chenyanfei-m

    "react-native-scrollable-tab-view": "^1.0.0",
    "@react-native-community/viewpager": "^3.3.0",
    "react-native": "^0.59.10"
    

    Thank u, those versions worked for me

  24. andresribeiro commented on Jun 18, 2021

    @andresribeiro

    yarn add @react-native-community/viewpager
    react-native link @react-native-community/viewpager
    and rebuild, solve it

    It worked with React Native version 0.64.2. Thanks!

  25. douglassoldan commented on Oct 8, 2021

    @douglassoldan

    @react-native-community/viewpager is deprecated!

    npm i react-native-pager-view
    cd ios
    pod install
    cd ..
    

    run projetc!

    Works here! ;-)

  26. deepakkathuria commented on Dec 23, 2021

    @deepakkathuria

    1.react-native link @react-native-community/viewpager
    2. npx react-native run-android
    3. npx react-native start

  27. zchuhui commented on Dec 29, 2021

    @zchuhui

    @react-native-community/viewpager is deprecated!

    npm i react-native-pager-view
    cd ios
    pod install
    cd ..
    

    run projetc!

    Works here! ;-)

    thanks bro!!!!

  28. Hudson-AmalembaL commented on Dec 13, 2023

    @Hudson-AmalembaL

    Make sure to

        clear the node_modules
        make a fresh install 

    then

    npm install  react-native-pager-view 
    npm install react-native-tab-view
    Restart the server

    That worked for me

  29. JustAiham commented on Aug 7, 2026

    @JustAiham

    For anyone in 2026, rebuilding and installing the new build might fix it.

    I did: eas build --platform android --profile development
    Then installed the build on my android and everything worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions