简体   繁体   English

Expo react-native 应用程序在手机上调试时工作,但发布的 apk 在启动时崩溃

[英]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;
};

Repository 存储库

Signed Apk 签名的 Apk

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检查这些问题并检查你的代码你可能会发现你做错了什么

  1. Click 点击
  2. Click 点击
  3. Click 点击
  4. Click 点击
  5. Click 点击

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

相关问题 Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android - Expo react-native app with firebase phone authentication works on web, error on ios simulator and crashes with no warning on Android React-native Expo App 崩溃且没有错误 - React-native Expo App crashes with no errors react-native android 应用程序在发布 apk 时崩溃 - react-native android app crashes with in release apk 按下登录表单提交时应用程序崩溃(使用生成的 APK 进行测试并安装在设备上) react-native - App crashes when login form submit is pressed (testing with generated APK and installed on device) react-native 使用“expo start”启动应用程序时没有问题,但打开“yarn react-native run-android”时出现问题 - No problem when starting app with "expo start" but problem when opening "yarn react-native run-android" 应用程序在调试期间在手机上工作,在安装apk时不起作用 - App works on phone during debugging, does not work when apk is installed 调试应用程序在本机中崩溃 - Debugging app crashes in react native 在React-Native Expo中购买应用程序吗? - In App Purchases in React-Native Expo? 反应原生(博览会)应用程序中的 Admob 未显示 - Admob in react-native (expo) app not displaying 置于后台时 React-Native 应用程序崩溃 - React-Native app crashes when put in Background
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM