添加Firebase crashlytics后,React本机App卡在启动屏幕上吗?

问题描述

我正在研究React Native App,它运行正常。但是,当我导入Firebase crashlytics时,如果我再次将其删除,则该应用程序会停留在启动屏幕上吗?

由于我是新来的反应者,所以我无法找到此问题的根本原因?

我正在尝试在波纹管中将index.js中的crashlytics导入

    //import '@react-native-firebase/crashlytics'
    or 
    //import {crashlytics} from '@react-native-firebase/crashlytics';
    or
    import crashlytics from '@react-native-firebase/crashlytics';

请提出根本原因,解决方案或解决此问题的方法。 请让我知道是否需要更多信息来了解此问题。

感谢您的帮助。

app.js

import React from "react"
import { YellowBox } from 'react-native';
import { View } from 'react-native';
import { Root } from "native-base"
import UserInactivity from 'react-native-user-inactivity';

import { Provider } from 'mobx-react';
import SplashScreen from 'react-native-splash-screen';
import AppNavigatorRoot,{ AppNavigationUtils } from "src/routers/navigations";
import store from 'src/store/';
import Loading from 'src/components/loading';
import Dialog from 'src/components/dialog';
import OAuthAPI from 'src/api/oauth';
import * as CoreConfig from 'src/config/config';
import HocErrorCatch from 'src/common/error';

index.js

import {AppRegistry} from 'react-native';
import App from './App';
// import {name as appName} from './app.json';
//import '@react-native-firebase/crashlytics'

//import {  } from '@react-native-firebase/crashlytics';
//import crashlytics from '@react-native-firebase/crashlytics';



AppRegistry.registerComponent("xyz",() => App);

错误日志

enter image description here

解决方法

您尝试导入软件包的方式不正确。您应该这样导入它

import crashlytics from '@react-native-firebase/crashlytics';

然后,您可以使用crashlytics 并记录任何事件。

这里是文档link。希望这能解决问题。

OP编辑问题后,此答案不再有效。 ,

我认为,单纯导入Crashlytics不会使您的应用停留在启动屏幕上。我认为您一定已经在启动屏幕上进行了一些crashlytics调用,因为您提到将其删除将使应用程序再次运行。

我想您正在使用RNFirebase v6。因此,请考虑执行以下操作:

import crashlytics from '@react-native-firebase/crashlytics';

componentDidMount(){
crashlytics().log('App started.');
}

上面的示例代码应该没有问题。有关更多信息,请refer here。还考虑在react-native-firebase/crashlytics处检查package.json的版本。我的项目中有"@react-native-firebase/crashlytics": "^8.1.2",

,

我同意汤米·梁的观点

我不认为纯粹导入Crashlytics会使您的应用陷入困境 启动画面


快速修复 安装react-native-splash-screen
App.js中使用此代码,它应该可以解决问题

     import SplashScreen from 'react-native-splash-screen';
    
    
    // inside useEffect or componentDidMount whichever you prefer
    componentDidMount() {
            // do stuff while splash screen is shown
            // After having done stuff (such as async tasks) hide the splash screen
            SplashScreen.hide();
    }

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...