Awesome
react-native-exceptions-manager
React-Native Crash Reporter In Release Version(Do not trigger native crash).
Linking
Android
- Add following lines into
android/settings.gradle
include ':react-native-exceptions-manager'
project(':react-native-exceptions-manager').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-exceptions-manager/android/app')
- Add following lines into your
android/app/build.gradle
in sectiondependencies
compile project(':react-native-exceptions-manager')
- Add following lines into
MainApplication.java
import com.richardcao.exceptionsmanager.react.ExceptionsManager;
...
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = Arrays.asList(
new MainReactPackage(),
...);
ArrayList<ReactPackage> packageList = new ArrayList<>(packages);
if (!BuildConfig.DEBUG) {
packageList.add(new ExceptionsManager());
}
return packageList;
}
- Create a class named
ReactNativeJSCrashReceiver
in it. This is needed to get js crash message fromreact-native-exceptions-manager
.
public class ReactNativeJSCrashReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals("com.richardcao.android.REACT_NATIVE_CRASH_REPORT_ACTION")) {
Throwable js = (Throwable) intent.getSerializableExtra("JavascriptException");
...(handler or report js crash operate)
Throwable e = (Throwable) intent.getSerializableExtra("Exception");
...(handler or report native crash operate)
}
}
}
- Add
ReactNativeJSCrashReceiver
declare in yourAndroidManifest.xml
<application
android:name=".MainApplication"
android:allowBackup="true"
...>
...
<receiver android:name=".ReactNativeJSCrashReceiver">
<intent-filter>
<action android:name="com.richardcao.android.REACT_NATIVE_CRASH_REPORT_ACTION" />
</intent-filter>
</receiver>
</application>
iOS
//TODO