react native (expo) crash when use drawer navigator

77 Views Asked by At

It works correctly in expo go, but after building and installing it on a physical or virtual Android device, the program does not work. That is, it stops after running the program.

App.js

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';
import { NavigationContainer } from "@react-navigation/native";
import { createDrawerNavigator } from "@react-navigation/drawer";
import Test from './page/Test';
import {
  SafeAreaView,
  SafeAreaProvider,
  SafeAreaInsetsContext,
  useSafeAreaInsets,
} from 'react-native-safe-area-context';
const Drawer = createDrawerNavigator();
export default function App() {
  return <SafeAreaProvider>
    <NavigationContainer>
      <Drawer.Navigator>
        <Drawer.Screen
          name="Test"
          component={Test}
        />
      </Drawer.Navigator>
    </NavigationContainer>
  </SafeAreaProvider>;
}

package.json

{
  "name": "msc",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@react-navigation/bottom-tabs": "^6.5.11",
    "@react-navigation/drawer": "^6.6.6",
    "@react-navigation/native": "^6.1.9",
    "@react-navigation/native-stack": "^6.9.17",
    "expo": "~49.0.15",
    "expo-status-bar": "~1.6.0",
    "react": "18.2.0",
    "react-native": "0.72.6",
    "react-native-reanimated": "~3.3.0",
    "react-navigation": "^5.0.0",
    "react-native-safe-area-context": "4.6.3"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0"
  },
  "private": true
}

eas.json

{
  "cli": {
    "version": ">= 5.2.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },
    "production": {}
  },
  "submit": {
    "production": {}
  }
}

I thought the problem was from the 'react-native-safe-area-context' and I added it, but the problem was not solved

0

There are 0 best solutions below