Expo React Native 应用程序在 Android 上崩溃

Mir*_*eia 11 android node.js reactjs react-native expo

自从我开始使用 Expo 使用 React Native 进行编程以来,我一直在使用 iOS 物理设备和 Expo 应用程序。我从来没有遇到过任何重大问题。

现在我想开始修复 Android 上的任何错误,但是当在我的 Android 物理设备上运行 Expo 应用程序时,Expo 应用程序在下载捆绑包时崩溃(关闭)。它不会在我的控制台中打印任何错误,所以我什至不知道从哪里开始......

这是我的 app.json:

{
  "expo": {
    "name": "PointoUserApp",
    "slug": "PointoUserApp",
    "version": "1.0.0",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "orientation": "portrait",
    "icon": "./assets/Images/icon.png",
    "splash": {
      "image": "./assets/Images/splash.png",
      "resizeMode":"contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "bundleIdentifier": "com.meretc23.PointoUserApp"
    },
    "android":{
      
    },
    "web": {
      "favicon": "./assets/Images/favicon.png"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

请注意,android下它是空的,因为我不知道需要什么。

下面也是我的 package.json 文件。

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo-google-fonts/inter": "^0.1.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.30",
    "@fortawesome/free-brands-svg-icons": "^5.14.0",
    "@fortawesome/free-solid-svg-icons": "^5.14.0",
    "@fortawesome/react-native-fontawesome": "^0.2.5",
    "@ionic/react": "^5.3.1",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/async-storage": "~1.11.0",
    "@react-native-community/datetimepicker": "2.4.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-navigation/bottom-tabs": "^5.7.3",
    "@react-navigation/material-top-tabs": "^5.2.16",
    "@react-navigation/native": "^5.7.2",
    "@react-navigation/stack": "^5.8.0",
    "@types/react-native-snap-carousel": "^3.8.2",
    "core-js": "^3.6.5",
    "expo": "^38.0.0",
    "expo-constants": "~9.1.1",
    "expo-font": "~8.2.1",
    "expo-linking": "^1.0.3",
    "expo-localization": "~8.2.1",
    "expo-location": "~8.2.1",
    "expo-permissions": "~9.0.1",
    "expo-status-bar": "^1.0.0",
    "firebase": "^7.21.1",
    "geolib": "^3.3.1",
    "i18n-js": "^3.7.1",
    "react": "16.11.0",
    "react-dom": "16.11.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
    "react-native-check-box": "^2.1.7",
    "react-native-gesture-handler": "~1.6.0",
    "react-native-localize": "^1.4.1",
    "react-native-map-clustering": "^3.3.9",
    "react-native-map-link": "^2.7.17",
    "react-native-maps": "0.27.1",
    "react-native-modal": "^11.5.6",
    "react-native-picker-select": "^8.0.0",
    "react-native-progress": "^4.1.2",
    "react-native-progress-circle": "^2.1.0",
    "react-native-qrcode-svg": "^6.0.6",
    "react-native-reanimated": "~1.9.0",
    "react-native-restart": "0.0.17",
    "react-native-safe-area-context": "^3.0.7",
    "react-native-screens": "~2.9.0",
    "react-native-snap-carousel": "^4.0.0-beta.5",
    "react-native-svg": "12.1.0",
    "react-native-tab-view": "^2.15.1",
    "react-native-web": "~0.11.7",
    "react-navigation": "^4.4.0",
    "react-navigation-stack": "^2.8.2",
    "react-redux": "^7.2.1",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "yargs-parser": "^18.1.3"
  },
  "devDependencies": {
    "@babel/core": "^7.8.6",
    "babel-preset-expo": "^8.2.3"
  },
  "private": true
}
Run Code Online (Sandbox Code Playgroud)

经验教训:如果您想在 ios 和 android 上运行应用程序,请始终同时监控这两个应用程序,以免您的应用程序太大而无法知道问题出在哪里......

感谢帮助

小智 6

我现在遇到了同样的问题。在我的情况下,我已将其范围缩小到 android adjustmentIcon 配置。如果我使用真实 png 的路径,应用程序会在捆绑包下载时崩溃。如果我不在android下包含adaptiveIcon,应用程序就会崩溃。它不会崩溃的唯一方法是包含链接到甚至不存在的文件的adaptiveIcon。这会记录一个错误,指出 Expo 找不到该文件,但应用程序实际上会加载。极其奇怪。尝试将其添加到您的 app.json 文件中。

"android": {
  "adaptiveIcon": {
    "foregroundImage": "./assets/anImageThatDoesNotExist.png",
    "backgroundColor": "#FFFFFF"
   }
 },
Run Code Online (Sandbox Code Playgroud)

  • 哇谢谢。这是一个奇怪的修复。一定要热爱软件。 (2认同)

小智 1

我的上一个博览会项目甚至没有 android 属性,而我的 ios 属性只有supportsTablet 为true。尝试完全删除 android 属性