react-native-exception-handler icon indicating copy to clipboard operation
react-native-exception-handler copied to clipboard

null is not an object (evaluating 'ReactNativeExceptionHandler.setHandlerforNativeException')'

Open bogdanpk opened this issue 5 years ago • 13 comments
trafficstars

Hi guys,

setJSExceptionHandler is working fine (without setNativeExceptionHandler) , but when I use setNativeExceptionHandler, I can't even run my app (it throw error before even starting the app):

null is not an object (evaluating 'ReactNativeExceptionHandler.setHandlerforNativeException')'

I tried to build .apk, it also doesn't work. I tested it on Android.

This is my code where I implement react-native-exception-handler


import React, { useState, useEffect } from 'react';
import { MyContextProvider } from './context/Context'
import AppStart from './AppStart'
import { Root } from "native-base";
import './i18next/i18n'
import { MenuProvider } from 'react-native-popup-menu';

import {  Alert } from 'react-native';
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler';

const errorHandler = (e, isFatal) => {
  if (isFatal) {
 
    Alert.alert(
        'Unexpected error occurred',
        `
        Error: ${(isFatal) ? 'Fatal:' : ''} ${e.name} ${e.message}
        We have reported this to our team ! Please close the app and start again!
        `,
      [{
        text: 'Close'
      }]
    );
  } else {
    console.log(e); // So that we can see it in the ADB logs in case of Android if needed
  }
};

setJSExceptionHandler(errorHandler, false);

 setNativeExceptionHandler((errorString) => {
   console.log(errorString);
}, false,); 

export default function App() {

  return (
    <MyContextProvider>
      <Root>
        <MenuProvider>
          <AppStart />
        </MenuProvider>
      </Root>
    </MyContextProvider>
  );
}

Any help?

Thank you

bogdanpk avatar May 17 '20 07:05 bogdanpk

Getting this kind of issue with 'react-navigation' version 5. Do you guys need more details?

vetrivendhan48 avatar May 30 '20 03:05 vetrivendhan48

Any solution for this? I have the same problem.

Josema avatar Sep 09 '20 14:09 Josema

Hi Josema,

Unfortunately, I didn't solve the issue.

On Wed, Sep 9, 2020 at 4:35 PM Josema Gonzalez [email protected] wrote:

Any solution for this? I have the same problem.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/a7ul/react-native-exception-handler/issues/128#issuecomment-689604093, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALK3OQE4BPO5G6PMMY6DD5DSE6HCPANCNFSM4NDIK73Q .

--

[image: facebook] http://www.facebook.com/ParkourSrbija [image: instagram] http://www.instagram.com/ParkourSrbija

Bogdan Cvetković

Parkour Srbija

0694053317 [email protected] www.pksrbija.com

bogdanpk avatar Sep 09 '20 21:09 bogdanpk

We also encountered this problem, any idea?

cuttlas avatar Oct 13 '20 09:10 cuttlas

You'll see this if the library is not linked natively. Make sure to link it and rebuild the app

salhotra avatar Oct 26 '20 18:10 salhotra

Same here

OoDeLally avatar Mar 06 '21 23:03 OoDeLally

Same here. Autolinking is not working or something

MCervenka avatar Apr 06 '21 16:04 MCervenka

Don't forget to run pod install!

cuttlas avatar Apr 11 '21 14:04 cuttlas

Still happening in 2022

alloverleague-dev avatar Mar 29 '22 03:03 alloverleague-dev

pod install fix this bug for me

afu-hive avatar Aug 05 '22 05:08 afu-hive

Hi, Same here. Any update?

AlpMehmet avatar Aug 15 '22 11:08 AlpMehmet

Got same issue...anybody take care ? or this package to be deprecated?

alickcai avatar Oct 18 '22 09:10 alickcai

Still happening in 2023! With React Native 0.68 which have autolinking by default...

w8ze-devel avatar Jan 12 '23 19:01 w8ze-devel