发布版APK启动时崩溃 - React Native

4

我有一个关于React Native发布APK的问题。

应用程序在调试模式下运行,但在发布模式下立即崩溃。

从logcat中得到了以下信息,这可能是导致此问题的原因。

Module AppRegistry is not a registered callable module (calling unmountApplicationComponentAtRootTag) 
11-01 08:28:24.531  6644  6662 E ReactNativeJS: undefined is not an object (evaluating 'd.View.propTypes.style')
11-01 08:28:24.534  6644  6662 E ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication)

这是我的软件包清单:
  {
  "name": "jbw",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "color": "^2.0.0",
    "intl": "^1.2.5",
    "native-base": "^2.3.3",
    "prop-types": "^15.6.0",
    "react": "16.0.0-beta.5",
    "react-native": "0.49.3",
    "react-native-fontawesome": "^5.7.0",
    "react-native-keyboard-aware-scroll-view": "^0.4.1",
    "react-native-linear-gradient": "^2.3.0",
    "react-native-loading-spinner-overlay": "^0.5.2",
    "react-native-masked-text": "^1.6.2",
    "react-native-modal": "^4.1.1",
    "react-native-popup-dialog": "^0.9.38",
    "react-native-super-grid": "^1.0.4",
    "react-native-vector-icons": "^4.4.2",
    "react-navigation": "^1.0.0-beta.15"
  },
  "devDependencies": {
    "babel-jest": "21.2.0",
    "babel-preset-react-native": "4.0.0",
    "jest": "21.2.1",
    "react-test-renderer": "16.0.0-beta.5"
  },
  "jest": {
    "preset": "react-native"
  }
}

你在哪里找到日志文件的? - PrinzAndreVonLandmann
你可以使用adb logcat来查看Android的日志。 - Ganesh Cauda
不知道这个,谢谢 :) - PrinzAndreVonLandmann
3个回答

5

我明白您的问题,是由于

View.PropTypes 

从0.49版本开始被废弃 应该转移到

import { ViewPropTypes } from 'react-native';

1
没有问题,似乎会出现更多与此更新相关的问题。 - Ganesh Cauda
我们需要将它添加到哪个文件中? - Anuj

0
尝试执行以下步骤:
  1. cd android
  2. sudo ./gradlew clean

如果不起作用,您可以检查您的index.android.js文件中的行:

AppRegistry.registerComponent('MyAppName', () => MyRootComponent);

验证(MyAppName)中的名称是否与MainActivity.java文件中的getMainComponentName()方法中的名称相同。


你好,感谢建议。我已经尝试过了,我的项目中所有文件都是正确的,在调试版本中运行良好,但问题只出现在发布版本中。你有什么想法是怎么回事吗? - Ganesh Cauda

0

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