简体   繁体   English

React Native 应用程序崩溃而没有错误日志,如何检测错误?

[英]React native app crash without error log ,How to detect a bug?

I'm developing an android app in react native and it is crash when I install it to my android device, my android device is running on android 10.我正在用 React Native 开发一个 android 应用程序,当我将它安装到我的 android 设备时它崩溃了,我的 android 设备在 android 10 上运行。

package.json包.json

{
  "name": "WifiSwitch",
  "version": "0.0.2",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.12.1",
    "@react-native-community/masked-view": "^0.1.10",
    "@react-native-community/viewpager": "^5.0.11",
    "@react-navigation/native": "^5.8.10",
    "@react-navigation/stack": "^5.12.8",
    "axios": "^0.21.1",
    "native-base": "^2.15.0",
    "react": "16.13.1",
    "react-native": "^0.65.1",
    "react-native-android-wifi": "^0.0.41",
    "react-native-best-viewpager": "^1.0.4",
    "react-native-gesture-handler": "^1.9.0",
    "react-native-image-picker": "^4.0.6",
    "react-native-reanimated": "^1.13.2",
    "react-native-safe-area-context": "^3.1.9",
    "react-native-screens": "^2.16.1",
    "react-native-tcp-socket": "^4.5.5",
    "react-native-uuid": "^2.0.1",
    "react-native-vector-icons": "^7.1.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "eslint": "^7.17.0",
    "jest": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

I recommend you to debug your application using adb logcat我建议您使用adb logcat调试您的应用程序

Steps to configure配置步骤

  1. Connect your device to your computer将您的设备连接到计算机

  2. Run adb devices to check out if your device is detected.运行adb devices以检查是否检测到您的设备。 If the command doesn't work because "adb is not a command", go to your ANDROID_HOME path, then open platform-tools如果该命令由于“adb 不是命令”而不起作用,请转到您的ANDROID_HOME路径,然后打开platform-tools

  3. Now run adb logcat : This command will output all logs (debug and error levels) coming from your Android Device.现在运行adb logcat :此命令将输出来自您的 Android 设备的所有日志(调试和错误级别)。

  4. Install your application again.再次安装您的应用程序。 I recommend you to use react-native run-android .我建议您使用react-native run-android More info: https://reactnative.dev/docs/running-on-device更多信息: https : //reactnative.dev/docs/running-on-device

  5. When your app is going to crash, you will see a Crash Log in the adb logcat output.当您的应用程序崩溃时,您将在adb logcat输出中看到崩溃日志。 Search for your app package name.搜索您的应用程序包名称。 For your convenience, you could as well have a look here to filter only your app: Filter LogCat to get only the messages from My Application in Android?为方便起见,您也可以查看此处仅过滤您的应用程序: Filter LogCat to get only the messages from My Application in Android?

Whenever you get a crash log, a stack trace is also provided.每当您获得崩溃日志时,还会提供堆栈跟踪。 That can help you trace the issue.这可以帮助您跟踪问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM