javascript - Integrating Crashlytics into React Native - Android -


i've set crashlytics integration ios our react native project, , have managed android version registered well. problem reports java/system related crashes - if there javascript exception thrown doesn't register reporting. working, ios version has functionality already.

i've set reporting outlined in fabric docs , this question - see second answer down, i've added oncreate in mainactivity.

following have attempted create own nativemodulecallexceptionhandler per this issue comment. code below:

package com.mypackage;  import com.facebook.react.bridge.nativemodule; import com.facebook.react.bridge.reactapplicationcontext; import com.facebook.react.bridge.reactcontext; import com.facebook.react.bridge.reactcontextbasejavamodule; import com.facebook.react.bridge.reactmethod; import com.facebook.react.modules.core.javascriptexception; import com.facebook.react.bridge.nativemodulecallexceptionhandler;  import java.util.map;  import com.crashlytics.android.crashlytics;  class crashlyticserrormodule extends reactcontextbasejavamodule {    public crashlyticserrormodule (reactapplicationcontext reactcontext) {     super(reactcontext);     addexceptionhandler(reactcontext);   }    @override   public string getname() {     return "crashlyticserrormodule";   }    private void addexceptionhandler(reactapplicationcontext reactcontext) {     reactcontext.setnativemodulecallexceptionhandler(new nativemodulecallexceptionhandler() {       @override       public void handleexception(exception e) {         if (e instanceof javascriptexception) {           crashlytics.log(e.getmessage());         } else {           crashlytics.logexception(e);         }       }     });   } 

the code compiles no errors, javascript exceptions still not being reported.

even when deliberately throwing runtime exceptions in oncreate() or @ end of addexceptionhandler() method, handleexception() not called. crashlytics notified however, exceptions getting caught somewhere!!

links source code in issue comment above.

https://github.com/facebook/react-native/issues/1194

in short: can use errorutils.setglobalhandler((err, isfatal) => { ... }); catch js exceptions , throw craslytics crashlytics.recordcustomexceptionname(...). react-native-fabric-crashlytics npm module can automatically.

don't forget add fabric.with(this, new crashlytics()) oncreate() method of mainapplication (or mainactivity if use rn lower 0.29).


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -