[英]React-native Expo App crashes with no errors
构建 apk 并将其安装在模拟器上进行测试后,应用程序崩溃且没有错误。 尝试了一些解决方案,但似乎都没有奏效。 该项目在博览会开始时运行顺利,但一旦安装在真实设备上,它就会崩溃。 在 Stackoverflow 和 Github 上检查了相同的问题,但似乎都没有解决我的问题。
包.json
{
"main": "index.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"test": "node ./node_modules/jest/bin/jest.js --watchAll"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@react-native-community/netinfo": "8.2.0",
"expo": "^45.0.0",
"expo-asset": "~8.5.0",
"expo-font": "~10.1.0",
"expo-location": "~14.2.2",
"expo-network": "~4.2.0",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "~1.3.0",
"expo-updates": "~0.13.3",
"firebase": "^9.9.0",
"map-nearest-location": "^1.1.4",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-beautiful-timeline": "^0.1.1",
"react-native-gesture-handler": "~2.2.1",
"react-native-link": "^4.1.0",
"react-native-maps": "0.30.2",
"react-native-safe-area-context": "4.2.4",
"react-native-safe-area-view": "^1.1.1",
"react-native-screens": "~3.11.1",
"react-native-timeline-flatlist": "^0.8.0",
"react-native-vector-icons": "^9.1.0",
"react-native-web": "0.17.7",
"react-navigation": "^4.4.4",
"react-navigation-stack": "^2.10.4",
"react-redux": "^7.2.6",
"redux": "^4.1.2",
"redux-thunk": "^2.4.1"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"babel-preset-expo": "~9.1.0",
"eslint": "^8.10.0",
"jest-expo": "^45.0.0",
"prettier": "^2.5.1"
},
"private": true
}
应用程序.json
{
"expo": {
"name": "demoapp",
"slug": "demoapp",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/images/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.demo.demoapp",
"versionCode": 1
}
}
}
应用程序.json
import React, {useCallback, useEffect, useState} from 'react';
import {Provider} from 'react-redux';
import {Platform, StatusBar, StyleSheet, View, LogBox} from 'react-native';
import {AppLoading} from 'expo';
import AppNavigator from './navigation/AppNavigator';
import * as SplashScreen from 'expo-splash-screen';
import * as Font from 'expo-font';
import store from './modules';
export default function App() {
const [appIsReady, setAppIsReady] = useState(false);
useEffect(() => {
// Ignore log notification by message:
LogBox.ignoreLogs(['Warning: ...']);
// Ignore all log notifications:
LogBox.ignoreAllLogs();
async function hideLoading() {
return await SplashScreen.hideAsync();
}
async function prepare() {
try {
await SplashScreen.preventAutoHideAsync();
// Pre-load fonts, make any API calls you need to do here
await Font.loadAsync({
'open-sans': require('./assets/fonts/OpenSans-Regular.ttf'),
'open-sans-bold': require('./assets/fonts/OpenSans-Bold.ttf'),
}).then(async () => {
await new Promise((resolve) => setTimeout(resolve, 1000)).then(() => {
setAppIsReady(true);
});
});
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
}
}
const result = prepare();
result.then(() => {
const isHide = hideLoading();
isHide.then(() => {
setAppIsReady(true);
});
});
});
if (!appIsReady) {
return null;
}
return (
<Provider store={store}>
<AppNavigator />
</Provider>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 20,
},
});
在深入挖掘之后,似乎这个包https://oblador.github.io/react-native-vector-icons/在真实设备上是错误的,删除它后,apk 安装并运行良好。 我需要找到另一个替代方案并在整个应用程序中进行更改,谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.