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

Cannot read property 'LENGTH_LONG' of undefined #43

Closed
gokulkulkarni1987 opened this issue Aug 18, 2017 · 44 comments
Closed

Cannot read property 'LENGTH_LONG' of undefined #43

gokulkulkarni1987 opened this issue Aug 18, 2017 · 44 comments

Comments

@gokulkulkarni1987
Copy link

When I try to include and run I get the following error,

screen shot 2017-08-18 at 12 24 20 pm

@cooperka
Copy link
Owner

Hi @gokulkulkarni1987, this means that the Snackbar object itself is undefined. Please make sure you've run react-native link react-native-snackbar successfully, then rebuild your app using react-native run-ios or react-native run-android.

@gokulkulkarni1987
Copy link
Author

@cooperka I am very new to React Native, so I do not know when react-native link react-native-snackbar will be successful.

I ran react-native link react-native-snackbar and also tried this link But still it did not work.

@cooperka
Copy link
Owner

Could you try running the example app and see if you spot any differences?

Here's my successful output for react-native link:

%> react-native link react-native-snackbar
Scanning 552 folders for symlinks in /home/react-native-snackbar/example/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 

@gokulkulkarni1987
Copy link
Author

gokulkulkarni1987 commented Aug 21, 2017

The example does work, I check my config with the config in this example and keep you posted.

@gokulkulkarni1987
Copy link
Author

hi @cooperka thanks it worked. I had issue with react-native version, after updating to latest version it did work. Thanks for your support.

@mattferrin
Copy link

Same problem using react-native 0.48.3 version and react-native-snackbar 0.4.1 version. Not sure how to resolve it as of yet...

@cooperka
Copy link
Owner

cooperka commented Sep 13, 2017

Hi @mattferrin, this error generally means the library wasn't linked properly or React Native can't find it. Can you please clear all your caches and try once more? Often something small gets in the way and the only solution is starting over.

@gokulkulkarni1987
Copy link
Author

Hi @cooperka I have upgraded my react-native version to 0.49.3 and I have started the getting the issue yet again. :(

Please find below the output of link,

sudo react-native link react-native-snackbar
rnpm-install info Android module react-native-snackbar is already linked 
rnpm-install info iOS module react-native-snackbar is already linked 

react-native: 0.49.3
react-native-snackbar: 0.4.2

please help me out.

@cooperka
Copy link
Owner

Hmm, I upgraded the example app to RN v0.49 and it all still seems to be working for me.

It's likely still a cache issue; try cleaning everything, including Xcode derived data, watchman, and the React Packager. I run into these sorts of issues occasionally, most often because Xcode is storing all sorts of derived data in various places. You can search online for ways of cleaning it up (unfortunately it's not as simple as just running Clean or deleting your project).

@mattferrin
Copy link

Tried everything, didn't work. But it works in fresh new project. Another one of those instances where the only fix is to create new project and then copy over, install, and link everything from scratch... Not the first time; not the last time.

@nclsjstnn
Copy link

i'm having this issue when i'm running the tests. i've done everything but nothing seems to work.
i'm on the last version of react-native (v0.50)

pls help

@mattferrin
Copy link

By the way, I created a new project and copied everything over, installed, and linked everything from scratch. It didn't work :) haha.

@alainib
Copy link

alainib commented Feb 15, 2018

i got this error on IOS only

"react": "^16.2.0",
"react-native": "^0.52.0"

I linked the package

  $react-native link react-native-snackbar
  Scanning folders for symlinks in ........../node_modules (31ms)
  rnpm-install info Android module react-native-snackbar is already linked 
  rnpm-install info iOS module react-native-snackbar is already linked 

If i import Snackbar from 'react-native-snackbar'; i get the same error

 Cannot read property 'LENGTH_LONG' of undefined

@cooperka
Copy link
Owner

cooperka commented Feb 15, 2018

Hmm, it looks like linking must have failed somehow even though it says it worked. This seems to happen to some people; try the manual linking solution here: #29 (comment)

@alainib
Copy link

alainib commented Feb 15, 2018

thanks @cooperka manually link remove the error ( https://facebook.github.io/react-native/docs/linking-libraries-ios.html )

@emersonmoura
Copy link

emersonmoura commented Mar 19, 2018

image
In Android the same error...
I did everything that is described here and in the documentation, but the error continues

"react-native": "0.51.0"
"react-native-snackbar": "^0.4.6",

image

image

@cooperka
Copy link
Owner

Hi @emersonmoura, have you tried manually linking?

@emersonmoura
Copy link

Hi @cooperka,
Yes...
I checked each file and the "link" was correct

Any hints of the exact reason? This way I can investigate better.

@cooperka
Copy link
Owner

Hmm, it's strange that it says "unmet peer dependency [email protected]" in your second screenshot. This lib requires >=0.40 so it's definitely satisfied.

Have you tried installing with Yarn instead of npm?

@emersonmoura
Copy link

I also found it strange...

Yes, I tried with Yarn. Result: Same red screen

@emersonmoura
Copy link

image

@cooperka
Copy link
Owner

As a last resort, you could try starting with the official example app and progressively make it similar to your own app and see where it breaks.

@emersonmoura
Copy link

emersonmoura commented Mar 20, 2018

image

Tried starting with the official example...

Is there a problem with my machine? I use the "elementary Os"

@cooperka
Copy link
Owner

It could very well be related to your OS. If the example app doesn't work, something larger is likely wrong. Please post back if you find a solution!

@andyngdz
Copy link

If you are using Pods. Go to ios folder then pod install.
screen shot 2018-05-11 at 9 20 38 pm

@ntwigs
Copy link

ntwigs commented Aug 2, 2018

I had this issue on Android and did the following to solve it:

  • Linked the Snackbar react-native link react-native-snackbar
  • Changed the distributionUrl in the file android/gradle/wrapper/gradle-wrapper.properties into:
    • https\://services.gradle.org/distributions/gradle-4.4-all.zip
  • Changed the buildscript dependency in the file android/build.gradle into:
    • classpath 'com.android.tools.build:gradle:3.1.3
  • Executed react-native run-android and voila - it worked! 🎉

@ghost
Copy link

ghost commented Aug 19, 2018

I got the same issue on iOS. I already linked it manually
(https://facebook.github.io/react-native/docs/linking-libraries-ios.html).
But still got the error.
screen shot 2018-08-19 at 10 00 54 pm

@efstathiosntonas
Copy link

@itanhduy If you are using Pods. Go to ios folder then pod install.

^^ this should definitely go into README. Thanks for pointing out.

@cooperka
Copy link
Owner

The manual installation guide is here, linked from the README. Feel free to edit the wiki if it needs improvement! Thanks.

@onmyway133
Copy link

After adding RNSnackBar.xcproj to Xcode (I recommend doing that manually instead of pod install), go to your app target -> Build Phrases -> Link Binary with Libraries and select RNSnackBar.a

@masterkrang
Copy link

woah, this bug is a nightmare, these devs should apologize. tried a lot of stuff, but no thanks, abort mission!

@juliobguedes
Copy link

juliobguedes commented Jul 18, 2019

@masterkrang I spent the last day trying to add this component to my app and couldnt do it. Today I decided to try once more and was able to add it (my app is ios only). Those were my steps:

  1. Add pod 'React', :path => '../node_modules/react-native' to the beginning of my Podfile
  2. npm i --save react-native-snackbar
  3. react-native link react-native-snackbar
  4. (Obviously optional) Fixed wrong indentation in my podfile (happened during link)
  5. cd ios/ && pod install
  6. Tried to react-native run-ios -> failed
  7. Tried to build using Xcode -> failed: 'folly/Portability.h' file not found
  8. Added these lines at the end of my Podfile:
post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == "React"
            target.remove_from_project
        end
    end
end

And it worked. Can you try these steps?

@thepday12
Copy link

You can try on Android

  • Step 1: run react-native link react-native-snackbar
  • Step 2: open MainApplication in getPackages add new SnackbarPackage() to List
import com.azendoo.reactnativesnackbar.SnackbarPackage;

public class MainApplication extends NavigationApplication {

protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList( new SnackbarPackage());
   }
}

@janoist1
Copy link

+1

@janoist1
Copy link

Ok, it turns out that for me the issue was due to not restarting the simulator. :-)

@dpisarevskiy
Copy link

hello! this solution don't work with expo..

@bravadomizzou
Copy link

Readme says this library doesn't support expo.... hopefully will soon?

@cooperka
Copy link
Owner

Hi @bravadomizzou, it's not that Snackbar doesn't support Expo, it's the opposite -- Expo doesn't support Snackbar. You can eject if you want to use Snackbar, or ask Expo to build it into their set of available native components.

@ImAbhishekTomar
Copy link

I am facing the same issue.

@simonheavenvolvo
Copy link

Getting the same error but in react-native-web only.

@Rushabhgedam
Copy link

manual linking also needs to be documented for iOS in readme,
I did pod install by adding this one pod 'RNSnackbar', :path => '../node_modules/react-native-snackbar/RNSnackbar.podspec'
works like charm for me

@smitkaswala
Copy link

Working well with Expo. :)

Snackbar.show({
text: 'Image Downloaded Successfully.',
duration: Snackbar.LENGTH_LONG ---> replace with static duration - '1000',
});

@alkanoidev
Copy link

@smitkaswala is there anything else i have to do?

@antonkoetzler
Copy link

@smitkaswala is there anything else i have to do?

Use another package lmfao

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

No branches or pull requests