react-native-screenguard: production crash on some devices java.lang.NullPointerException
Still receiving
Fatal Exception: java.lang.NullPointerException java.util.Objects.requireNonNull (Objects.java:203) com.screenguard.ScreenGuardModule.lambda$deactivateShield$2$com-screenguard-ScreenGuardModule (ScreenGuardModule.java:101)
using 0.3.0-stable
Usage:
` function initScreenGuard() { try { ScreenGuardModule.register( //insert any hex color you want here, default black if null or empty ‘#FF0000’, () => { alert(“Screenshots are not allowed!”); }); } catch (e) { console.warn(“ScreenGuardModule.register”, e); } }
useEffect(() => {
initScreenGuard();
console.log(“initScreenGuard()”);
return () => {
ScreenGuardModule.unregister();
console.log(“ScreenGuardModule.unregister()”);
};
}, []);
`
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 16 (10 by maintainers)
Commits related to this issue
- fix: resolve #24 and #29 — committed to gbumps/react-native-screenguard by deleted user 8 months ago
Just to note: no crashes so far either on ios/android with the fixed version, using it on larger active userbase!
The fix is working, no crashes so far! Also being tested on ios in live app.
It could be somehow when calling
deactivateShield
at native, at the 1st time callgetReactApplicationContext().getCurrentActivity()
, this is still not null yet. Unluckily, at 2nd call after checking, it became null -> crash.Relax, the problem is way a few percent and the gap between those call
getReactApplicationContext().getCurrentActivity()
too little, but I still provide a quick fix for you if you want to:No crashes! The fix definitely works!
Thank you! Seems OK in the fresh realase! Waiting for more data from firebase to be sure. I’ll push it to another app with larger user base if it looks stable for a good while. That will probably reveal any hidden bugs if there is any, hopefully none:)
yes, please do the same with the
deactivateShield
as well and recheck carefully before I could apply this fix for next release