React Native App crashes when i open it on my real android device with no errors on console in emulator

huangapple go评论64阅读模式
英文:

React Native App crashes when i open it on my real android device with no errors on console in emulator

问题

我正在构建一个React Native应用程序。当我首次开始构建并完成了其中的两个屏幕后,我创建了APK文件并将其安装在我的设备上,它完美地打开了,没有崩溃。但现在,我几乎完成了它,它在启动屏幕后崩溃了。我正在安装它在一台安卓6.0系统的HTC Desire 10 Pro手机上。

我尝试通过在我的Android Studio设备上从Expo打开JS调试器来调试它是否有任何错误,但屏幕上没有显示任何错误。你能帮助我了解可能的问题是什么吗?我需要删除package-lock.json吗?

以下是我的package.json:

{
    "name": "f1ian",
    "version": "1.0.0",
    "main": "node_modules/expo/AppEntry.js",
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web"
    },
    "dependencies": {
        "@react-native-async-storage/async-storage": "1.17.11",
        "@react-navigation/bottom-tabs": "^6.5.7",
        "@react-navigation/drawer": "^6.6.2",
        "@react-navigation/native": "^6.1.6",
        "@react-navigation/stack": "^6.3.16",
        "axios": "^1.4.0",
        "expo": "~48.0.18",
        "expo-constants": "~14.2.1",
        "expo-status-bar": "~1.4.4",
        "expo-web-browser": "^12.1.1",
        "react": "18.2.0",
        "react-native": "0.71.8",
        "react-native-gesture-handler": "~2.9.0",
        "react-native-reanimated": "~2.14.4",
        "react-native-safe-area-context": "4.5.0"
    },
    "devDependencies": {
        "@babel/core": "^7.20.0"
    },
    "private": true
}

以下是我的eas文件:

{
  "cli": {
    "version": ">= 3.6.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "ios": {
        "resourceClass": "m1-medium"
      }
    },
    "preview": {
      "distribution": "internal",
      "ios": {
        "resourceClass": "m1-medium"
      }
    },
    "production": {
      "ios": {
        "resourceClass": "m1-medium"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

以下是我的app.json文件:

{
    "expo": {
        "name": "f1ian",
        "slug": "f1ian",
        "version": "1.0.0",
        "orientation": "portrait",
        "icon": "./App/assets/icon.png",
        "userInterfaceStyle": "light",
        "splash": {
            "image": "./App/assets/splash.png",
            "resizeMode": "contain",
            "backgroundColor": "#ffffff"
        },
        "updates": {
            "fallbackToCacheTimeout": 0
        },
        "assetBundlePatterns": ["**/*"],
        "ios": {
            "supportsTablet": true
        },
        "android": {
            "package": "com.f1ian.f1ian",
            "versionCode": 1,
            "adaptiveIcon": {
                "foregroundImage": "./App/assets/adaptive-icon.png",
                "backgroundColor": "#FFFFFF"
            }
        },
        "web": {
            "favicon": "./App/assets/favicon.png"
        },
        "extra": {
            "eas": {
                "projectId": "f5f4f061-dc1b-46a3-9474-4ce7f3c8dc36"
            }
        }
    }
}

希望这些信息对解决你的问题有所帮助。如果你有进一步的问题,请随时提出。

英文:

I am building a react native app, when i first started the build after i completed 2 screens of it, i created the apk file and installed it on my device, it opened perfectly without any crash. But now that i almost have it complete, it is crashing after the splash screen, i am installing it on an HTC desire 10 pro which has android 6.0 on it.

what i tried is debugg it if it has any error by opening the JS debugger from expo on my android studio device but no errors are shown on screen. Can you please help me to know what might be the problem with it ?
do i need to delete package-lock.json ?

here is my package.json:

`{
    "name": "f1ian",
    "version": "1.0.0",
    "main": "node_modules/expo/AppEntry.js",
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web"
    },
    "dependencies": {
        "@react-native-async-storage/async-storage": "1.17.11",
        "@react-navigation/bottom-tabs": "^6.5.7",
        "@react-navigation/drawer": "^6.6.2",
        "@react-navigation/native": "^6.1.6",
        "@react-navigation/stack": "^6.3.16",
        "axios": "^1.4.0",
        "expo": "~48.0.18",
        "expo-constants": "~14.2.1",
        "expo-status-bar": "~1.4.4",
        "expo-web-browser": "^12.1.1",
        "react": "18.2.0",
        "react-native": "0.71.8",
        "react-native-gesture-handler": "~2.9.0",
        "react-native-reanimated": "~2.14.4",
        "react-native-safe-area-context": "4.5.0"
    },
    "devDependencies": {
        "@babel/core": "^7.20.0"
    },
    "private": true
}`

here is my eas file:

{
  "cli": {
    "version": ">= 3.6.0"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal",
      "ios": {
        "resourceClass": "m1-medium"
      }
    },
    "preview": {
      "distribution": "internal",
      "ios": {
        "resourceClass": "m1-medium"
      }
    },
    "production": {
      "ios": {
        "resourceClass": "m1-medium"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

app.json file

{
    "expo": {
        "name": "f1ian",
        "slug": "f1ian",
        "version": "1.0.0",
        "orientation": "portrait",
        "icon": "./App/assets/icon.png",
        "userInterfaceStyle": "light",
        "splash": {
            "image": "./App/assets/splash.png",
            "resizeMode": "contain",
            "backgroundColor": "#ffffff"
        },
        "updates": {
            "fallbackToCacheTimeout": 0
        },
        "assetBundlePatterns": ["**/*"],
        "ios": {
            "supportsTablet": true
        },
        "android": {
            "package": "com.f1ian.f1ian",
            "versionCode": 1,
            "adaptiveIcon": {
                "foregroundImage": "./App/assets/adaptive-icon.png",
                "backgroundColor": "#FFFFFF"
            }
        },
        "web": {
            "favicon": "./App/assets/favicon.png"
        },
        "extra": {
            "eas": {
                "projectId": "f5f4f061-dc1b-46a3-9474-4ce7f3c8dc36"
            }
        }
    }
}

答案1

得分: 1

问题在于我最后构建的屏幕中,"Platform"没有从"react-native"中导入。所以,对于任何遇到这个问题的人,请查看导入部分。

英文:

The problem was that in the last screen i built, "Platform" wasn't imported from "react-native". So to anyone who is facing this issue, look at the imports.

huangapple
  • 本文由 发表于 2023年6月8日 02:07:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76425991.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定