Expo react-native app works when debugging on phone but released apk crashes on start

Viewed 73

I am new to react-native and created a straightforward app (just a home page basically, not yet finished) using expo and published it. It works fine when debugging with web or expo android app but the built app crashes on start. I am not sure what is wrong.

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

{
  "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:

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

1 Answers

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
Related