Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native App crashes on Launch Screen on device

I'm starting with React Native, everything works fine in the iOS simulator. I decide to try it on a device.

The app launches, I can play with it, I close/reopen it around 4 or 5 times, and then somewhat randomly the app crashes on Launch Screen (the one with "Powered By React Native"). It just shows the screen, and the app crashes to the iPhone home screen.

Any idea how I can further debug that?

Edit: I added Bugsnag in my AppDelegate.m, but bugsnag doesn't detect anything when the app crashes.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  NSURL *jsCodeLocation;

  [BugsnagReactNative start];

  // Rest of code  

}
like image 736
jeanpaul62 Avatar asked Mar 26 '17 14:03

jeanpaul62


People also ask

Why is my app crashing as soon as I open it?

Apps on Android can crash because of low storage space, too many apps running simultaneously, a weak internet connection, or not having the proper app updates installed.


2 Answers

I came across this issue today. Read a few SO posts and saw one guy mentioned if your app launches and hangs on the splash screen and then crashes with no error it probably has something to one of your npm dependencies.

After digging deeper i saw the react packager was throwing the error

This error is caused by a @providesModule declaration with the same name across two different files.

To fix

  1. check / clean up dependencies(check for same name declerations)

  2. rm -rf node_modules

  3. rm -rf $TMPDIR/react-*

  4. npm i

like image 200
Zolve Avatar answered Oct 17 '22 23:10

Zolve


This can caused by many issues it seems. Recently this happened to me and I had to search a bit to find out the exact reason. I'll save you guys the trouble by sharing few places I read - https://github.com/facebook/react-native/issues/14500#issuecomment-348063910 - https://github.com/facebook/react-native/issues/17276#issuecomment-357538208

In my case it was a library issue which I have not linked properly.

-https://github.com/ivpusic/react-native-image-crop-picker/issues/204

So yeah! my point is, it's something we have done or not done. Bit more research would help!!!

like image 27
shehanrg Avatar answered Oct 17 '22 23:10

shehanrg