ios React Native App 在设备的启动屏幕上崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43030067/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
React Native App crashes on Launch Screen on device
提问by amaurymartiny
I'm starting with React Native, everything works fine in the iOS simulator. I decide to try it on a device.
我从 React Native 开始,在 iOS 模拟器中一切正常。我决定在设备上尝试一下。
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.
应用程序启动,我可以玩它,我关闭/重新打开它大约 4 到 5 次,然后应用程序在启动屏幕上随机崩溃(带有“Powered By React Native”的那个)。它只显示屏幕,应用程序崩溃到 iPhone 主屏幕。
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.
编辑:我在 AppDelegate.m 中添加了 Bugsnag,但是当应用程序崩溃时,bugsnag 没有检测到任何内容。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSURL *jsCodeLocation;
[BugsnagReactNative start];
// Rest of code
}
回答by Zolve
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.
我今天遇到了这个问题。阅读一些 SO 帖子,看到有人提到如果您的应用程序启动并挂在启动屏幕上,然后崩溃而没有错误,它可能与您的 npm 依赖项之一有关。
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.
This error is caused by a @providesModule declaration with the same name across two different files.
To fix
修理
check / clean up dependencies(check for same name declerations)
rm -rf node_modules
rm -rf $TMPDIR/react-*
npm i
检查/清理依赖项(检查同名声明)
rm -rf node_modules
rm -rf $TMPDIR/react-*
npm i
回答by shehanrg
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
这似乎是由许多问题引起的。最近这发生在我身上,我不得不搜索一下以找出确切原因。我会通过分享我读过的几个地方来为你们省去麻烦 - 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
- 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!!!
是的!我的观点是,这是我们做过或没有做过的事情。更多的研究会有所帮助!!!
回答by Rakesh
I was also facing the same issue on real device and it was working fine on simulator. So, i have fixed my issue by given solution
我在真实设备上也遇到了同样的问题,并且在模拟器上运行良好。所以,我已经通过给定的解决方案解决了我的问题
Solution: i have uninstall the application from simulator and then installed it again. This time it showed me the actual error on simulator that i had made mistake.
解决方案:我已经从模拟器中卸载了应用程序,然后重新安装了它。这次它向我展示了我在模拟器上犯的实际错误。
回答by user602525
I had this problem also, what triggered it for me though was updating react and react-native.
我也遇到了这个问题,虽然是更新 react 和 react-native 触发了它。
I did a build after updating and then I experienced the same issue. I downgraded back to the previous versions of react and react-native, but that didn't work for me.
我在更新后做了一个构建,然后我遇到了同样的问题。我降级回以前版本的 react 和 react-native,但这对我不起作用。
I tried removing node modules, and reinstalling, that didn't help. Then I noticed that when I was building: react-native run-ios
,
我尝试删除节点模块并重新安装,但没有帮助。然后,我注意到,当我是建设:react-native run-ios
,
the files in ios/buildwere not updating
ios/build中的文件没有更新
I rm -rf ios/build/
and then I react-native run-ios
and the ios/build folder populated. My app ran fine after that.
我rm -rf ios/build/
然后我react-native run-ios
和 ios/build 文件夹填充。之后我的应用程序运行良好。
回答by Sujit
For me lottie package was creating problem. After removing the package able to launch the package.
对我来说,lottie 包正在制造问题。删除包后就可以启动包了。
Make sure by checking the last package/packages installed
通过检查最后安装的包/包来确保