Monday, 19 September 2022

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. 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



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

No comments:

Post a Comment