[英]React Native Release APK only Android Crash
我的apk调试正常!
建立APK版本行之有效!
当我将设备安装到设备时崩溃并从以下问题开始:
亚行日志猫
E AndroidRuntime: Process: br.com.missionbrasil, PID: 10382
E AndroidRuntime: java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Strict mode does not allow function declarations in a lexically nested statement. (index.android.bundle:4)
E AndroidRuntime: at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:24)
E AndroidRuntime: at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:172)
E AndroidRuntime: ... 7 more
W ActivityManager: Force finishing activity br.com.missionbrasil/.MainActivity
我将所有条件=> { vars && (<View></View>) } to { vars ?: }
清洁./gradlew 100次...
package.json
"dependencies": {
"@expo/react-native-fade-in-image": "^1.1.1",
"@expo/react-native-touchable-native-feedback-safe": "^1.1.2",
"autobind-decorator": "^1.3.4",
"babel-core": "^6.26.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"react": "16.0.0",
"react-addons-update": "^15.6.2",
"react-native": "^0.51.0",
"react-native-image-crop-picker": "^0.19.1",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0"
},
"devDependencies": {
"babel-jest": "21.2.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-preset-react-native": "4.0.0",
"jest": "21.2.1"
},
"jest": {
"preset": "react-native"
}
有人遇到同样的问题吗?
问候。
SyntaxError:严格模式不允许在词法嵌套语句中进行函数声明
请按照下面概述的步骤搜索并替换node_modules文件夹中的3个字符串:
步骤1 | NativeModules.js
/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js
function normalizePrefix(moduleName: string)
const normalizePrefix = function(moduleName: string)
步骤2 | UIManager.js
/node_modules/react-native/Libraries/Utilities/UIManager.js
function normalizePrefix(moduleName: string)
const normalizePrefix = function(moduleName: string)
步骤3 | InitializeJavascriptAppEngine.js
node_modules\\react-native\\Libraries\\JavaScriptAppEngine\\Initialization\\InitializeJavaScriptAppEngine.js
function handleError(e, isFatal)
var handleError = function(e, isFatal)
步骤4 | npm start--重置缓存
替换所有字符串后,运行npm start -- --reset-cache
,它现在应该可以工作了
我只是清理.babelrc中的所有插件,并且像魅力一样工作。
像这样:
{
"presets": [
"react-native"
]
}
我的问题的原因是=>“ transform-es2015-modules-commonjs”
感谢克雷格的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.