React-Native:应用在启动时崩溃

时间:2018-07-11 11:48:02

标签: react-native react-native-android react-native-ios

我的应用程序在本地服务器上运行正常,没有任何问题。但是,当我尝试生成Release版本时,它无法正常工作。单击图标,应用程序立即崩溃。我试图检查ViewPropTypes并在必要的地方进行更新。但是仍然有同样的问题。

这是日志:

07-12 15:02:49.003 2675-2675/? I/Timeline: Timeline: Activity_launch_request time:50777871 intent:Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=IDENTIFERNAME/.MainActivity bnds=[53,264][175,386] (has extras) }
07-12 15:02:49.010 1399-2562/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=IDENTIFERNAME/.MainActivity bnds=[53,264][175,386] (has extras)} from uid 10027 on display 0
07-12 15:02:49.048 1399-2562/? D/Boost: hostingType=activity, hostingName=IDENTIFERNAME/.MainActivity, callerPackage=com.miui.home, isSystem=true, isBoostNeeded=false.
07-12 15:02:49.048 1399-2562/? I/ActivityManager: Start proc 30529:IDENTIFERNAME/u0a471 for activity IDENTIFERNAME/.MainActivity caller=com.miui.home
07-12 15:02:49.100 2614-2784/? I/WtProcessController: MOVE TO FOREGROUND: IDENTIFERNAME 10471
07-12 15:02:49.100 2614-2784/? I/StatusController: Last foreground:com.miui.home uid:10027 Current foreground:IDENTIFERNAME uid:10471
07-12 15:02:49.100 2614-2784/? I/WtProcessController: FOREGROUND INFO: name=IDENTIFERNAME uid=10471 pid=30529 TaskId:140
07-12 15:02:49.287 30529-30553/? V/FA: App package, google app id: IDENTIFERNAME, 1:110722844580:android:2c647de8d50b0447
07-12 15:02:49.293 30529-30553/? I/FA: To enable faster debug mode event logging run:
                                         adb shell setprop debug.firebase.analytics.app IDENTIFERNAME
07-12 15:02:49.302 30529-30529/? V/fb-UnpackingSoSource: locked dso store /data/user/0/IDENTIFERNAME/lib-main
07-12 15:02:49.304 30529-30529/? I/fb-UnpackingSoSource: dso store is up-to-date: /data/user/0/IDENTIFERNAME/lib-main
07-12 15:02:49.304 30529-30529/? V/fb-UnpackingSoSource: releasing dso store lock for /data/user/0/IDENTIFERNAME/lib-main
07-12 15:02:49.409 30529-30529/? D/AccessibilityManager: current package=IDENTIFERNAME, accessibility manager mIsFinalEnabled=false, mOptimizeEnabled=true, mIsUiAutomationEnabled=false, mIsInterestedPackage=false
07-12 15:02:49.483 30529-30566/? I/art: Thread[22,tid=30566,Native,Thread*=0xe48a4d00,peer=0x12c7d670,"Thread-4"] recursive attempt to load library "/data/app/IDENTIFERNAME-1/lib/arm/libfb.so"
07-12 15:02:49.807 1399-1472/? I/ActivityManager: Displayed IDENTIFERNAME/.MainActivity: +773ms
07-12 15:02:49.807 1399-1472/? I/Timeline: Timeline: Activity_windows_visible id: ActivityRecord{9279ddf u0 IDENTIFERNAME/.MainActivity t140} time:50778675
07-12 15:02:49.867 2939-29226/? V/FA-SVC: Event recorded: Event{appId='IDENTIFERNAME', name='user_engagement(_e)', params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=2636, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=4013702848528184958}]}
07-12 15:02:49.911 2939-29226/? V/FA-SVC: Event recorded: Event{appId='IDENTIFERNAME', name='screen_view(_vs)', params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-4603722032159587411}]}
07-12 15:02:51.431 30529-30581/? I/ReactNativeJS: Running application "StreetTune" with appParams: {"rootTag":1}. __DEV__ === false, development-level warning are OFF, performance optimizations are ON
07-12 15:02:51.532 1399-5932/? D/LocationManagerService: request 5c27842 gps Request[ACCURACY_FINE gps requested=+100ms fastest=+100ms] from IDENTIFERNAME(10471)
07-12 15:02:51.537 1399-5932/? D/LocationManagerService: request 20da689 network Request[POWER_LOW network requested=+1s0ms fastest=+1s0ms] from IDENTIFERNAME(10471)
07-12 15:02:51.580 30529-30583/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
                                                   Process: IDENTIFERNAME, PID: 30529
                                                   com.facebook.react.common.JavascriptException: Module JSTimers is not a registered callable module (calling callTimers), stack:
                                                   value@30:2875
                                                   <unknown>@30:955
                                                   value@30:2417
                                                   value@30:927

                                                       at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:56)
                                                       at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:40)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
                                                       at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
                                                       at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
                                                       at android.os.Handler.handleCallback(Handler.java:754)
                                                       at android.os.Handler.dispatchMessage(Handler.java:95)
                                                       at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
                                                       at android.os.Looper.loop(Looper.java:163)
                                                       at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
                                                       at java.lang.Thread.run(Thread.java:760)
07-12 15:02:51.636 2614-21189/? I/ActiveController: loadActiveApp type: 4, name: IDENTIFERNAME, uid: 10471, pid: 0, status: 10
07-12 15:02:51.671 1649-1649/? V/ExpandedNotification: push score:0.0, local score:0.0, pkg:IDENTIFERNAME
07-12 15:02:51.673 1649-1649/? D/PhoneStatusBar: addNotification pkg=IDENTIFERNAME;basepkg=com.android.systemui;id=252119
07-12 15:02:51.795 2939-29226/? V/FA-SVC: Event recorded: Event{appId='IDENTIFERNAME', name='app_exception(_ae)', params=Bundle[{firebase_event_origin(_o)=crash, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-4603722032159587411, timestamp=1531387971585, fatal=1}]}
07-12 15:02:51.889 2939-29226/? V/FA-SVC: Event recorded: Event{appId='IDENTIFERNAME', name='user_engagement(_e)', params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=2279, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-4603722032159587411}]}
07-12 15:02:51.894 2614-2784/? I/WtProcessController: Receive am_crash event for pid: 30529 pkg = IDENTIFERNAME
07-12 15:02:51.894 2614-2784/? W/KloServer: Aborted broadcast does not supprt for: IDENTIFERNAME
07-12 15:02:51.898 1399-2562/? W/ActivityManager:   Force finishing activity IDENTIFERNAME/.MainActivity
07-12 15:02:51.989 2614-2784/? I/StatusController: Last foreground:IDENTIFERNAME uid:10471 Current foreground:com.miui.home uid:10027
07-12 15:02:52.075 1399-5932/? I/WindowManager: WIN DEATH: Window{91f64f4 u0 IDENTIFERNAME/IDENTIFERNAME.MainActivity}
07-12 15:02:52.076 1399-1562/? I/ActivityManager: Process IDENTIFERNAME (pid 30529) has died: vis  +99T 
07-12 15:02:52.164 2675-2675/? I/Launcher.ApplicationsMessage: update IDENTIFERNAME/ to null

有人可以帮我解决这个问题吗?

enter image description here

3 个答案:

答案 0 :(得分:1)

最后,我花了4天才得到答案。问题是Android将在index.android.js中包含旧版本文件。其中的代码是以前的版本,因此会产生问题。在iOS中,随着我们删除 build 文件夹的解决方法。

尝试创建需要react-native的新文件。以下是有助于解决此问题的命令。

Android:

react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

iOS:

react-native bundle --platform ios  --dev false --assets-dest ./ios --entry-file index.ios.js --bundle-output ios/main.jsbundle

答案 1 :(得分:0)

一些调试技巧:

  1. 如果您使用的是Android,则可以使用以下命令运行Android应用的调试版本: 生产包从开发设置中禁用开发包。

  2. 如果需要,还可以启用minify来查找这是否是一个     减少问题。

  3. 另一个坏主意是生成生产版本并打开     捆绑文件并导航到837:1752,这样您就会知道     这在哪里发生。

如果可以的话,我看不到日志中的任何错误,     完成日志?

答案 2 :(得分:0)

您可以检查以下几件事:

  1. 是否启用了构建保护程序?如果是,则禁用并尝试运行并检查。您将了解确切的错误和obj详细信息。

  2. 用于调试和发布的环境是否相同? -您尝试在null对象上调用login_type。

  3. 您可以在调用login_type的位置添加空检查并测试发布版本。

  4. 如果没有任何效果,请使用最后一个选项-集成错误提示崩溃报告。这真的是很酷的javascript库,它将提供有关崩溃的更多详细信息。

谢谢。