[英]Expo react-native app works when debugging on phone but released apk crashes on start
I am new to react-native and created a straightforward app (just a home page basically, not yet finished) using expo and published it.我是 react-native 的新手,并使用 expo 创建了一个简单的应用程序(基本上只是一个主页,尚未完成)并发布了它。 It works fine when debugging with web or expo android app but the built app crashes on start.
使用 web 或 expo android 应用程序调试时它工作正常,但构建的应用程序在启动时崩溃。 I am not sure what is wrong.
我不确定出了什么问题。
app.json app.json
{
"expo": {
"name": "milwaukee-internationals",
"slug": "milwaukee-internationals",
"version": "1.0.1",
"orientation": "portrait",
"owner": "amir734jj",
"description": "Milwaukee Internationals",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 0
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"backgroundColor": "#FFFFFF"
},
"package": "com.amir734jj.milwaukeeinternationals",
"versionCode": 2
},
"web": {
"favicon": "./assets/favicon.png"
},
"plugins": [
"expo-notifications"
],
"extra": {
"eas": {
"projectId": "a9aa3f6d-ea5b-4f0e-aa92-0ae5f2ebb814"
}
}
}
}
package.json package.json
{
"name": "milwaukee-internationals",
"version": "0.0.1",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"@expo/webpack-config": "^0.17.0",
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-navigation/drawer": "^6.4.4",
"@react-navigation/native": "^6.0.12",
"@react-navigation/native-stack": "^6.8.0",
"@reduxjs/toolkit": "^1.8.5",
"expo": "~46.0.9",
"expo-application": "~4.2.2",
"expo-constants": "~13.2.4",
"expo-device": "~4.3.0",
"expo-notifications": "~0.16.1",
"expo-status-bar": "~1.4.0",
"expo-updates": "~0.14.5",
"fastestsmallesttextencoderdecoder": "^1.0.22",
"nanoid": "^4.0.0",
"react": "18.0.0",
"react-dom": "18.0.0",
"react-native": "0.69.5",
"react-native-dotenv": "^3.3.1",
"react-native-gesture-handler": "~2.5.0",
"react-native-logs": "^5.0.1",
"react-native-reanimated": "~2.9.1",
"react-native-render-html": "^6.3.4",
"react-native-safe-area-context": "4.3.1",
"react-native-screens": "~3.15.0",
"react-native-web": "~0.18.7",
"react-redux": "^8.0.2"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"eslint": "^8.23.1",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0"
},
"private": true,
"author": "amir734jj"
}
webpack.config.js: webpack.config.js:
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
const constants = require('./constants');
// Expo CLI will await this method so you can optionally return a promise.
// eslint-disable-next-line func-names
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(env, argv);
// Maybe you want to turn off compression in dev mode.
if (config.mode === 'development') {
config.devServer.proxy = {
'/api': {
target: constants.API_BASE_URL,
secure: false,
changeOrigin: true,
},
};
config.devServer.clientLogLevel = 'info';
config.devServer.compress = false;
}
// Or prevent minimizing the bundle when you build.
if (config.mode === 'production') {
config.optimization.minimize = false;
}
// Finally return the new config for the CLI to use.
return config;
};
Your app is crashing due to this error this is a crash log of your app you may be messed up some import or something.由于此错误,您的应用程序崩溃这是您的应用程序的崩溃日志,您可能会搞砸一些导入或其他事情。 sometimes it works in debug or you are not opening that screen in debug.
有时它可以在调试中工作,或者您没有在调试中打开该屏幕。 debug only shows an error when you access that screen or file but in release it crashes in startup if its related import or routing
调试仅在您访问该屏幕或文件时显示错误,但在发布时,如果其相关的导入或路由,它会在启动时崩溃
2022-09-20 16:09:10.973 23712-23759/? E/unknown:ReactNative: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
This error is located at:
in Unknown
in Unknown
in RCTView
in Unknown
in RCTView
in Unknown
in b, stack:
Ii@35:89340
<unknown>@35:40603
Fl@35:58157
xa@35:92676
vi@35:83678
gi@35:83606
hi@35:83371
oi@35:80340
oi@-1
xt@35:27446
ni@35:77138
ji@35:91646
<unknown>@35:97778
<unknown>@348:1279
run@339:1403
runApplication@339:2420
value@61:3579
<unknown>@61:758
value@61:2582
value@61:730
value@-1
check these questions and check your code you might find what you did wrong检查这些问题并检查你的代码你可能会发现你做错了什么
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.