EXPO [Android] [EAS]应用程序在启动时崩溃构建问题

6

我最近从SDK 43迁移到Expo SDK 45,并从传统构建升级到了EAS CLI,使用的是托管工作流。

当我使用命令eas build --profile preview --platform android创建Android版本时,它成功地创建了版本,但在启动画面崩溃,没有任何堆栈跟踪信息。

在使用dev客户端或Expo GO测试版本时,没有任何错误或警告。

这里分享我的package.json文件。

{
  "name": "native",
  "version": "1.0.0",
  "private": "true",
  "main": "./index.js",
  "scripts": {
    "postinstall": "patch-package; cp -f patches/manual/createKeyboardAwareNavigator.js ./node_modules/@react-navigation/native/src",
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "eject": "expo eject",
    "test": "node ./node_modules/jest/bin/jest.js --watchAll",
    "prettier": "prettier --write 'src/**/*{.js,.jsx}'",
    "lint": "eslint -c ../../.eslintrc 'src' --ext '.js,.jsx'",
    "lint-fix": "eslint -c ../../.eslintrc 'src' --ext '.js,.jsx' --fix",
    "fix-nav": "cp -f patches/manual/createKeyboardAwareNavigator.js ./node_modules/@react-navigation/native/src"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "@expo/browser-polyfill": "0.0.1-alpha.3",
    "@expo/metro-config": "^0.5.1",
    "@expo/react-native-action-sheet": "^3.0.3",
    "@react-native-community/datetimepicker": "6.1.2",
    "@react-native-community/segmented-control": "2.1.1",
    "@react-native-picker/picker": "^2.4.8",
    "babel-plugin-inline-dotenv": "^1.3.3",
    "date-and-time": "2.0.1",
    "deprecated-react-native-prop-types": "^3.0.1",
    "expo": "^45.0.0",
    "expo-app-loading": "~2.0.0",
    "expo-battery": "~6.2.0",
    "expo-brightness": "~10.2.0",
    "expo-camera": "~12.2.0",
    "expo-constants": "~13.1.1",
    "expo-dev-client": "~1.0.1",
    "expo-device": "~4.2.0",
    "expo-document-picker": "~10.2.1",
    "expo-file-system": "~14.0.0",
    "expo-image-manipulator": "~10.3.1",
    "expo-image-picker": "~13.1.1",
    "expo-linear-gradient": "~11.3.0",
    "expo-linking": "~3.1.0",
    "expo-local-authentication": "~12.2.0",
    "expo-localization": "~13.0.0",
    "expo-location": "~14.2.2",
    "expo-modules-core": "~0.9.2",
    "expo-notifications": "~0.15.4",
    "expo-permissions": "~13.2.0",
    "expo-radio-button": "^1.0.8",
    "expo-screen-capture": "~4.2.0",
    "expo-screen-orientation": "~4.2.0",
    "expo-splash-screen": "~0.15.1",
    "expo-status-bar": "~1.3.0",
    "expo-task-manager": "~10.2.1",
    "expo-updates": "~0.13.4",
    "expo-web-browser": "~10.2.1",
    "geolib": "^3.0.4",
    "gl-matrix": "^3.3.0",
    "i18n-js": "^3.3.0",
    "invariant": "^2.2.4",
    "lodash": "^4.17.11",
    "memoize-one": "^5.1.1",
    "mobx": "^4.2.0",
    "mobx-persist": "^0.4.1",
    "mobx-react": "^5.0.0",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.31",
    "native-base": "2.13.8",
    "patch-package": "^6.2.0",
    "postinstall-postinstall": "^2.0.0",
    "prop-types": "^15.7.2",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.68.2",
    "react-native-btr": "^1.1.4",
    "react-native-calendars": "^1.1254.0",
    "react-native-chart-kit": "^4.0.0",
    "react-native-datepicker": "^1.7.2",
    "react-native-floating-action": "^1.20.0",
    "react-native-geocoding": "^0.5.0",
    "react-native-gesture-handler": "~2.2.1",
    "react-native-get-random-values": "~1.8.0",
    "react-native-gifted-chat": "0.16.3",
    "react-native-keyboard-aware-scroll-view": "^0.9.3",
    "react-native-loading-spinner-overlay": "^2.0.0",
    "react-native-maps": "0.30.2",
    "react-native-masked-text": "^1.12.3",
    "react-native-modal": "^11.10.0",
    "react-native-multiple-select": "^0.5.9",
    "react-native-options-menu": "^2.0.2",
    "react-native-paper": "4.12.0-alpha.0",
    "react-native-picker-select": "7.0.0",
    "react-native-root-toast": "3.3.0",
    "react-native-screens": "~3.11.1",
    "react-native-slider": "^0.11.0",
    "react-native-svg": "12.3.0",
    "react-native-svg-transformer": "^0.14.3",
    "react-native-swipe-gestures": "^1.0.5",
    "react-native-table-component": "^1.2.1",
    "react-native-tableview-simple": "^2.4.1",
    "react-native-typography": "^1.4.0",
    "react-native-vector-icons": "^8.1.0",
    "react-native-web": "0.17.7",
    "react-native-webview": "11.18.1",
    "react-navigation": "3.11.0",
    "rn-pdf-reader-js": "^4.1.1",
    "rn-tooltip": "^3.0.0",
    "sentry-expo": "^4.2.0",
    "socket.io-client": "^1.7.1",
    "superagent": "^5.0.7",
    "superagent-promise": "^1.1.0",
    "uuidv4": "^6.2.13"
  },
  "devDependencies": {
    "babel-eslint": "^10.0.3",
    "babel-preset-expo": "~9.1.0",
    "eslint": "^5.16.0",
    "eslint-config-airbnb": "^17.1.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-jsx-a11y": "^6.1.2",
    "eslint-plugin-react": "^7.11.1",
    "jest-expo": "^45.0.0",
    "prettier": "^2.0.5",
    "@babel/core": "^7.12.9"
  }
} 

app.json

{
  "expo": {
    "name": "Norsktimeregister",
    "slug": "native-norsk-2",
    "privacy": "public",
    "entryPoint": "./index.js",
    "platforms": [
      "ios",
      "android"
    ],
    "orientation": "default",
    "version": "1.16.1",
    "icon": "./assets/images/app-icon2.png",
    "splash": {
      "image": "./assets/images/splash-logo.png",
      "resizeMode": "contain",
      "backgroundColor": "#222D93"
    },
    "hooks": {
      "postPublish": [
        {
          "file": "sentry-expo/upload-sourcemaps",
          "config": {
            "organization": "Norsktime",
            "project": "NorsktimeRN",
            "authToken": "************************************************"
          }
        }
      ]
    },
    "updates": {
      "enabled": false
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "bundleIdentifier": "com.tidogkontroll.norsktime",
      "googleServicesFile": "./GoogleService-Info.plist",
      "infoPlist": {
        "NSCameraUsageDescription": "Norsktimeregister uses the camera to immediately add images to time logs.",
        "NSPhotoLibraryUsageDescription": "Norsktimeregister needs access to your photo library to let you add images to time logs.",
        "NSLocationAlwaysUsageDescription": "Norsktimeregister needs to access your location to automatically stamp you in/out.",
        "NSLocationUsageDescription": "Norsktimeregister needs to access your location to automatically stamp you in/out.",
        "NSLocationWhenInUseUsageDescription": "Norsktimeregister needs to access your location to automatically stamp you in/out.",
        "NSLocationAlwaysAndWhenInUseUsageDescription": "Norsktimeregister needs to access your location to automatically stamp you in/out.",
        "UIBackgroundModes": [
          "location",
          "fetch"
        ],
        "LSApplicationQueriesSchemes": [
          "http",
          "https"
        ]
      },
      "supportsTablet": true,
      "config": {
        "googleMapsApiKey": "********************",
        "usesNonExemptEncryption": false
      },
      "usesIcloudStorage": true,
      "requireFullScreen": true,
      "buildNumber": "1"
    },
    "android": {
      "googleServicesFile": "./google-services.json",
      "config": {
        "googleMaps": {
          "apiKey": "**************************"
        }
      },
      "versionCode": 136,
      "package": "com.tidogkontroll.norsktime",
      "permissions": [
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION",
        "CAMERA",
        "MANAGE_DOCUMENTS",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE",
        "RECEIVE_BOOT_COMPLETED",
        "WRITE_SETTINGS"
      ],
      "softwareKeyboardLayoutMode": "pan",
      "useNextNotificationsApi": true
    },
    "extra": {
      "eas": {
        "projectId": "*************************"
      }
    }
  }
}

eas.json

{
  "cli": {
    "version": ">= 2.9.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      },
      "ios": {
        "simulator": true
      }
    },
    "preview": {
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      },
      "ios": {
        "simulator": true
      }
    },
    "production": {}
  },
  "submit": {
    "production": {}
  }
}

我们已经尝试了不同的方法,比如创建自定义入口点和默认入口点。

请有人帮忙看一下,任何帮助都将不胜感激。 提前致谢。


这个问题解决了吗?我也遇到了同样的问题。 - undefined
5个回答

5
在您的安卓设备上启用调试模式(如果不知道如何操作,可以在谷歌/YouTube 上搜索)。完成后,使用 USB 线将其连接到电脑上。
然后,在命令提示符中输入“adb”命令,确保已安装 Android 调试桥(Android Debug Bridge)。如果没有安装,请安装。
接着,键入“adb devices”命令,以查看是否能够为 adb 看到您的安卓设备。如果您看到了自己的设备,请键入以下命令:
adb logcat "*:E"
“adb” 允许与安卓设备通信。 “logcat” 显示安卓设备的系统和应用程序日志。 “*:E”:仅显示错误级别(E 代表错误)的日志。
然后在您的手机上启动应用程序,一旦它崩溃,请在终端中检查您的日志。您应该会看到一行:
--------- beginning of crash
然后是关于崩溃的其他信息。例如,我有以下内容:
--------- beginning of crash FATAL EXCEPTION: create_react_context java.lang.RuntimeException:无法加载脚本。请确保您正在运行 Metro blablabla...
这将为您提供有关问题的更多信息。

2

我曾经遇到过这个问题,原因是启动画面。尝试从你的app.json中删除启动画面配置。


0
我不得不安装“react-native-screens”和“react-native-safe-are-of-context”,然后再次在EAS上构建,最终才能正常工作。希望这对你有所帮助。

0
就我而言,在我的手机上调试应用程序后,我发现如果你使用的是expo,react-native-gesture-handler是缺失的,在文档中我们必须安装它并将其导入到index.jsApp.js中。

0
我遇到了类似的问题,原因是我使用了Envalid这个包。如果环境变量缺失,Envalid会抛出一个错误。这导致我的应用在启动时崩溃。
虽然这可能是一个比较特殊的问题,但我还是想发帖,以防其他人遇到类似的问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接