简体   繁体   English

React Native Expo Android 仅在生产中崩溃,并且在 Sentry 中也无法捕获

[英]React Native Expo Android crashes only in production and is also not catchable in Sentry

Already tried to look into all different problems here on StackOverflow with related titles, like this one .已经尝试在 StackOverflow 上用相关标题来研究所有不同的问题,比如这个 But no success.但没有成功。

Here is the piece of code where the problem happens:这是发生问题的一段代码:

const fetchApi = useCallback(async () => {
  setIsLoading(true);

  if (activePortfolioId) {
    try {
      const response = await getApis().portfoliosApi.getPortfolioOverviewById(
        activePortfolioId
      );
      if (response.data && response.data?.tickers?.length) {
        setItems(handleListItems(response.data.tickers));
      }
    } catch (error) {
      Sentry.Native.captureException(error);
      Sentry.Native.captureMessage('HELLO?');
      Alert.alert(
        'Sorry!',
        'We were unable to retrieve the performance list. Please try again later.'
      );
    } finally {
      setIsLoading(false);
    }
  }
}, [activePortfolioId]);

So what happens is, on iOS I have no problem at all here, either on DEV or PROD, using real device or simulator, everything works fine, never went to the catch statement.所以发生的事情是,在 iOS 上我完全没有问题,无论是在 DEV 还是 PROD 上,使用真实设备或模拟器,一切正常,从未使用catch语句。 On Android, using simulator or real device with Expo, it's all fine too, even using expo start --no-dev --minify to try to reproduce the app as PROD, occurs no errors at all.在Android上,使用模拟器或带有Expo的真实设备,一切都很好,即使使用expo start --no-dev --minify尝试将应用程序复制为PROD,也完全没有错误。 I have tried everything that came on my mind, like removing pieces of the code to see if the problem stops.我已经尝试了所有我想到的东西,比如删除代码片段以查看问题是否停止。 Like instead of calling the API, just setting the items, like this:就像不调用 API 一样,只需设置项目,如下所示:

setItems(handleListItems(response.data.tickers)); because I also thought that the problem might be with my handler function, I also tried to just do setItems([{ OBJECT HERE }]);因为我还认为问题可能出在我的处理函数上,所以我也尝试只做setItems([{ OBJECT HERE }]); . . The problem has just stopped once I stopped setting the items.一旦我停止设置项目,问题就停止了。 So I also tried to check my renderItem function, tried to stop using any styled component, just what React Native provides, nothing works.所以我也尝试检查我的renderItem函数,尝试停止使用任何styled化的组件,就像 React Native 提供的一样,没有任何效果。 Then I decided to bring Sentry to my code but even with Sentry, no issues is shown there.然后我决定将 Sentry 带入我的代码,但即使使用 Sentry,那里也没有显示任何问题。 I open the screen, it is loading, fetches the API, then it falls in the catch block, because I see the Alert on Android and then the app crashes and go back to the splash screen frozen.我打开屏幕,它正在加载,获取 API,然后它落入catch块中,因为我在 Android 上看到了Alert ,然后应用程序崩溃并返回冻结的初始屏幕。 The only issue that appeared on Sentry was: Sentry 上出现的唯一问题是:

Could not open URL 'https://XXXXXXX': No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://XXXXXXX... flg=0x10000000 }

But strangely I have never clicked on this during the "tests" and this link just appears on the login screen, shouldn't have anything to do with the problem itself, right?但奇怪的是,我在“测试”期间从未点击过此链接,并且此链接仅出现在登录屏幕上,应该与问题本身无关,对吧?

I really don't know what else I could try to do and figure out what is causing this problem, so decided to ask for help and maybe find someone who already went through something similar.我真的不知道我还能做些什么并找出导致这个问题的原因,所以决定寻求帮助,也许找到已经经历过类似事情的人。

Thanks!谢谢!

PS: I'm using TS too, so apparently no problems with some possible undefined or whatever. PS:我也在使用 TS,所以对于一些可能的未定义或其他问题显然没有问题。

Found the issue, it was with the Intl .发现了问题,它与Intl有关。 Solution here .解决方案在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM