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

Undefined not an object (_reactNative.nativeModules.RNSnackbar,.LENGTH.LONG_ #29

Closed
Jazz747 opened this issue May 8, 2017 · 21 comments
Closed

Comments

@Jazz747
Copy link
Contributor

Jazz747 commented May 8, 2017

screenshot_2017-05-08-11-56-20-544_hr aduro midway

On app start, crashes a few seconds later
RN 0.42.3, linked, error appears when putting the import statement in JS

@ghost
Copy link

ghost commented May 8, 2017

Same with mine too.

@cooperka
Copy link
Owner

cooperka commented May 8, 2017 via email

@ghost
Copy link

ghost commented May 8, 2017

Ok, i would do that

@Jazz747
Copy link
Contributor Author

Jazz747 commented May 9, 2017

The problem still persists after cleaning the project in Android studio, deleting node_modules and doing npm install.

I've recently upgraded to RN 0.42.3 from 0.38, getting
npm WARN react-native@0.42.3 requires a peer of react@~15.4.1 but none was installed.
installed the aforementioned version of React, warning still persists but everything works. Don't know if that has anything to do with this issue.

@iRoachie
Copy link
Contributor

iRoachie commented May 9, 2017

This looks like a link error. @Jazz747 After you npm install, run react-native link react-native-snackbar then start your packager and build the app

@Jazz747
Copy link
Contributor Author

Jazz747 commented May 9, 2017

I did, result:
Cannot parse yarn version: 0.27 Scanning 467 folders for symlinks in /home/username/Projects/project/node_modules (2ms)
rnpm-install info Android module react-native-snackbar is already linked
rnpm-install info iOS module react-native-snackbar is already linked

Manual install instructions would be helpful, I see the snackbar inclusion in settings.gradle and app/build.gradle but not anywhere else, not sure if it should be included in MainApplication file

@iRoachie
Copy link
Contributor

iRoachie commented May 9, 2017

Yes it should be in MainApplication.java

import com.azendoo.reactnativesnackbar.SnackbarPackage;

// Then in class
 @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
            new SnackbarPackage(),
      );
    }

@Jazz747
Copy link
Contributor Author

Jazz747 commented May 9, 2017

Yep, that fixed it :)

I've had multiple problems in the past with linking of libraries, had to do it manually, so it would be cool if there were manual installation instructions on the main page also. Cheers!

@iRoachie
Copy link
Contributor

iRoachie commented May 9, 2017

@Jazz747 Awesome! If you could send a PR with the manual steps i'm sure @cooperka wouldn't mind.

@Jazz747
Copy link
Contributor Author

Jazz747 commented May 10, 2017

I'm somewhat unfamiliair on how to create pull requests since I'm new to Github, so I'll just make it here, in hopes that @cooperka can paste it into the description section if he wants to.

In android/settings.gradle:

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

In android/app/build.gradle:

dependencies {
...
    compile project(':react-native-snackbar')
...
}

In MainApplication.java:

import com.azendoo.reactnativesnackbar.SnackbarPackage;  // <- add this

@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
          new MainReactPackage(),
          new SnackbarPackage(), // <- add this
      );
    }

@iRoachie
Copy link
Contributor

@Jazz747 Made a video showing you how! https://www.useloom.com/share/3f9227d502a54ff3b049e8b2d5fc1327

@Jazz747
Copy link
Contributor Author

Jazz747 commented May 10, 2017

Wow man, my own personal instructional video :D I thought I had to git pull the entire project, make changes there and push. This is totally easy :) appreciate the effort, doing it now ;)

@Jazz747 Jazz747 closed this as completed May 10, 2017
@haseebnaseem
Copy link

I am having the same problem on iOS. Any help ?

@cooperka
Copy link
Owner

@haseebnaseem have you tried the solutions suggested above? There are several things which could be wrong, usually fixed by cleaning all your caches and starting fresh.

@haseebnaseem
Copy link

@cooperka yes I have tried. Nothing works.

@cooperka
Copy link
Owner

@haseebnaseem Are you able to install and run the example app?

@haseebnaseem
Copy link

@cooperka fatal error: 'React/RCTBridgeModule.h' file not found when trying to build the example app.

@cooperka
Copy link
Owner

Hmm, is it possible you have some custom configuration on your machine? Do other projects work for you? Make sure you've run yarn cache clean before yarn install. I'm not really sure what could be going on for you, sorry 😕

@davidbilik
Copy link

davidbilik commented Jan 28, 2018

I had the same problem on iOS, I ran the react-native link command that said everything is correctly linked, but the truth was that nothing was linked :D I had to do manual linking as described here https://facebook.github.io/react-native/docs/linking-libraries-ios.html and then its working beautifully

@egemon
Copy link

egemon commented May 8, 2018

@cooperka meet the same issue. Please add reference to the bottom of the readme in the top. Updating gradle helped me, but I first read all these threads about this error, before finding real solution at the bottom of readme.

@cooperka
Copy link
Owner

cooperka commented Apr 9, 2019

Note that this is currently documented on the README here, please refer all comments to #43. I'm going to lock this issue in order to unify the conversation there. Thanks!

Repository owner locked as resolved and limited conversation to collaborators Apr 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants