How to resolve Undefined is not an object (evaluating 'RCTToastAndroid.TOAST') - react-native

I want to run a react-native app. Before, it runs normally. An then when I add a sound and I run it again it show Undefined is not an object (evaluating 'RCTToastAndroid.SHORT')
I already open another stackoverflow question like this but it not resolve my problem

Looking at the error, even without any code from you, I have some assumptions.
You are probably trying to implement Android Toast in your app.
In the react-native docs there is an example of how to do it here and you are getting an error because of it.
Please Provide the full code where you are implementing it so we can get an proper solution.
By what you posted in your answer, there is some error in implementing Android's Toast.
OR
You have the Toast module implemented correctly, but your are in an IOS device and in you can't use Android's Toast in IOS.
If this is your case, you can try implementing something different to display and use react native Plataform.select to render the Toast in Android and something else in IOS.

Related

How to find which React Native module is causing a crash

I have a React Native app. It works well most of the time, but in our automated error detection framework, I can see some users infrequently run into a crash in React Native. There is a SIGABRT and a bunch of lines like this in the stack trace:
facebook::react::JSIExecutor::defaultTimeoutInvoker
I'm reasonably confident that the issue isn't directly in my application's code -- not only is the stacktrace all React Native stuff, but one of my coworkers triggered the error right after logging in a couple times, and I've never triggered this error myself despite testing the login flow many times.
Other websites make it seem like the error might actually be in a native module (but not React Native itself), but I wasn't able to figure out how to debug which native module it could be (the error doesn't happen often enough to easily just try disabling native modules one by one or anything like that).
Is there a way to get more information about what is actually causing a crash when the crash is in native code?
Thanks!

How to change device wallpaper with react native (in 2021)

I am trying to build an app which can change the wallpaper.. I tried using react-native-manage-wallpaper to do the same; but I am getting this error:
TypeError: null is not an object (evaluating '_reactNative.NativeModules.WallPaperManager.setWallpaper')
I have explained this problem here in detail:
I am getting an error while using manage-wallpaper library in react native
I have also tried solutions described here and here
But I haven't yet got any useful solution anywhere...Is there a way to do the same task using any other library?

React native I put a splash screen in app.js and I get an error

This error code appeared on the connected iPhone. I need help.
I will write additional app.js code as needed.
According to the error message, .length is being called on an undefined object. Take a look at AppIntroSlider, see if the issue is with this component.

Recording Crash using Crashlytics AFTER overridin JSExceptionHandler (React Native)_

I'm using Crashlytics (Natively) in React Native.
In RN, I'm overriding the JSExceptionHandler to use NativeModules and call out to my MyCrashHandler.
MyCrashHandler does the with Crashlytics reportError.. but this is only good if I THEN have a crash.
I can't have a Crashlytics crash because I already overrode the JSExceptionHandler.
How do I force Crashlytics to send my events? Maybe I need to use Firebase logging instead?
You don't have to wait for a crash to know that Crashlytics is working. You can use the SDK to force a crash by adding the following code to your app
Button crashButton = new Button(this);
crashButton.setText("Crash!");
Also, you can use your own API like this:
Fabric.with([Crashlytics.start(withAPIKey: "YOUR_API_KEY")]
You can write your own custom crash report by writing code in native iOS and Android. Please check the following the link for it.
https://firebase.google.com/docs/crashlytics/customize-crash-reports?platform=ios

Background timer with Expo

Need to get the timer going even if the app is running in backgroung.
Trying to use react-native-background-timer library to do so, but getting this error:
undefined is not an object (evaluating 'RNBackgroundTimer.setTimeout)
On some research got to know that I will have to eject expo to be able to use this.
Is there a way to do this with expo?
Yes actually within Expo itself you can use their Background Fetch API to handle all background tasks, it uses TaskManager under the hood to do that. You don't need to use react-native-background-timer.
Further details of this API and application is found here.
Hope this Helps!