我有一个React Native项目,可以在Emulator上成功运行。我还将调试APK安装到我的Android手机上,并且按预期工作。但是当我将此APK创建为带签名的APK时,它会立即与
崩溃xxx申请已停止
结果。
作为logcat,错误发生在index.android.bundle文件中(setGlobalHandler(function(e,r){try {l.handleException(e,r)} catch(r){throw //console.log('无法打印错误:',r.message),e})
Here is my package.json file.
{
"name": "xxx",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"react-devtools": "react-devtools",
"release-android": "cd android && ./gradlew assembleRelease && open app/build/outputs/apk/release"
},
"dependencies": {
"accordion-collapse-react-native": "^0.1.6",
"moment": "^2.21.0",
"native-base": "2.3.5",
"react": "16.0.0",
"react-native": "0.51.0",
"react-native-collapse-view": "^1.0.0",
"react-native-communications": "^2.2.1",
"react-native-device-info": "0.21.2",
"react-native-document-picker": "^2.2.0",
"react-native-drawer": "^2.5.1",
"react-native-google-static-map": "^0.1.11",
"react-native-htmlview": "^0.12.1",
"react-native-image-progress": "^1.0.1",
"react-native-keyboard-aware-scroll-view": "^0.8.0",
"react-native-maps": "^0.21.0",
"react-native-modal": "^5.2.0",
"react-native-modal-dropdown": "^0.6.1",
"react-native-open-maps": "^0.1.3",
"react-native-swiper": "^1.5.13",
"react-native-vector-icons": "4.3.0",
"react-navigation": "^2.0.4",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-form": "^7.2.1",
"redux-saga": "^0.16.0"
},
"devDependencies": {
"babel-jest": "22.0.4",
"babel-preset-react-native": "4.0.0",
"jest": "22.0.4",
"react-test-renderer": "16.0.0"
},
"resolutions": {
"uglify-es": "3.2.2"
},
"jest": {
"preset": "react-native"
},
"rnpm": {
"assets": [
"./src/assets/fonts/"
]
}
}
这是我的LogCat
12-21 11:03:03.431 23435-23454/? E/ReactNativeJNI: Got JS Exception: Unexpected token '//console.log('Failed to print error: ',r.message),e}})}u('Promise',function(){return r(62)}),u('regeneratorRuntime',function(){return delete e.regeneratorRuntime,r(67),e.regeneratorRuntime});var c=function(e){u(e,function(){return r(22)[e]})};c('setTimeout'),c('setInterval'),c('setImmediate'),c('clearTimeout'),c('clearInterval'),c('clearImmediate'),c('requestAnimationFrame'),c('cancelAnimationFrame'),c('requestIdleCallback'),c('cancelIdleCallback'),u('XMLHttpRequest',function(){return r(68)}),u('FormData',function(){return r(79)}),u('fetch',function(){return r(80).fetch}),u('Headers',function(){return r(80).Headers}),u('Request',function(){return r(80).Request}),u('Response',function(){return r(80).Response}),u('WebSocket',function(){return r(82)}),u('Blob',function(){return r(83)}),u('URL',function(){return r(90)}),e.alert||(e.alert=function(e){r(91).alert('Alert',''+e)});var s=e.navigator;void 0===s&&(e.navigator=s={}),i(s,'product',function(){return'ReactNative'}),i(s,
12-21 11:03:03.431 23435-23454/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: com.xxx.ppm, PID: 23435
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Unexpected token '//console.log('Failed to print error: ',r.message),e}})}u('Promise',function(){return r(62)}),u('regeneratorRuntime',function(){return delete e.regeneratorRuntime,r(67),e.regeneratorRuntime});var c=function(e){u(e,function(){return r(22)[e]})};c('setTimeout'),c('setInterval'),c('setImmediate'),c('clearTimeout'),c('clearInterval'),c('clearImmediate'),c('requestAnimationFrame'),c('cancelAnimationFrame'),c('requestIdleCallback'),c('cancelIdleCallback'),u('XMLHttpRequest',function(){return r(68)}),u('FormData',function(){return r(79)}),u('fetch',function(){return r(80).fetch}),u('Headers',function(){return r(80).Headers}),u('Request',function(){return r(80).Request}),u('Response',function(){return r(80).Response}),u('WebSocket',function(){return r(82)}),u('Blob',function(){return r(83)}),u('URL',function(){return r(90)}),e.alert||(e.alert=function(e){r(91).alert('Alert',''+e)});var s=e.navigator;void 0===s&&(e.navigator=s={}),i(s,'product',function(){return'ReactNative'}),i(s,'geolocation',function(){return r(93)});var f=r(16);f.registerLazyCallableModule('Systrace',function(){return r(19)}),f.registerLazyCallableModule('JSTimers',function(){return r(22)}),f.registerLazyCallableModule('HeapCapture',function(){return r(96)}),f.registerLazyCallableModule('SamplingProfiler',function(){return r(97)}),f.registerLazyCallableModule('RCTLog',function(){return r(98)}),f.registerLazyCallableModule('RCTDeviceEventEmitter',function(){return r(30)}),f.registerLazyCallableModule('RCTNativeAppEventEmitter',function(){return r(99)}),f.registerLazyCallableModule('PerformanceLogger',function(){return r(100)}),e.fetchBundle=function(e,n){var t=r(15).BundleFetcher;if(!t)throw new Error('BundleFetcher is missing');t.fetchBundle(e,function(e){if(e){var r=new Error(e.message);r.code=e.code,n(r)}n(null)})}},55);
'. Expected expression after 'throw'. (index.android.bundle:57)
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:24)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:172)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:499)
at com.facebook.react.bridge.CatalystInstanceImpl.access$900(CatalystInstanceImpl.java:40)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:515)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:33)
at android.os.Looper.loop(Looper.java:148)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:818)
Caused by: com.facebook.react.devsupport.JSException: Unexpected token '//console.log('Failed to print error: ',r.message),e}})}u('Promise',function(){return r(62)}),u('regeneratorRuntime',function(){return delete e.regeneratorRuntime,r(67),e.regeneratorRuntime});var c=function(e){u(e,function(){return r(22)[e]})};c('setTimeout'),c('setInterval'),c('setImmediate'),c('clearTimeout'),c('clearInterval'),c('clearImmediate'),c('requestAnimationFrame'),c('cancelAnimationFrame'),c('requestIdleCallback'),c('cancelIdleCallback'),u('XMLHttpRequest',function(){return r(68)}),u('FormData',function(){return r(79)}),u('fetch',function(){return r(80).fetch}),u('Headers',function(){return r(80).Headers}),u('Request',function(){return r(80).Request}),u('Response',function(){return r(80).Response}),u('WebSocket',function(){return r(82)}),u('Blob',function(){return r(83)}),u('URL',function(){return r(90)}),e.alert||(e.alert=function(e){r(91).alert('Alert',''+e)});var s=e.navigator;void 0===s&&(e.navigator=s={}),i(s,'product',function(){return'ReactNative'}),i(s,'geolocation',function(){return r(93)});var f=r(16);f.registerLazyCallableModule('Systrace',function(){return r(
答案 0 :(得分:0)
我想更新所有出现类似错误的人。我删除了 yourReactProject / android / app / src / main / assets 根目录下的资产文件夹。然后,我使用此shell命令“ react-native bundle重新生成它–platform android --dev false –entry-file index.js --bundle-output android / app / src / main / assets / index.android .bundle --assets-dest android / app / src / main / res“ ,请注意,我的react项目以index.js文件开头。如果您的项目以不同的.js文件开头,请使用您的起始.js文件更改此行。 “ --entry-file index.js”