wn-na / react-native-capture-protection

It’s a library for React Native to control simple capture events(i.e. Screenshot or Screen record)
https://www.npmjs.com/package/react-native-capture-protection
MIT License
102 stars 10 forks source link

NPE on Android 8/9 #14

Closed murat-mehmet closed 1 year ago

murat-mehmet commented 1 year ago

Here's the error I'm getting on Android 8 or 9 devices. On newer devices it is working fine.

Fatal Exception: java.lang.NullPointerException: Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' on a null object reference
       at android.os.Handler.<init>(Handler.java:239)
       at android.hardware.display.DisplayManagerGlobal$DisplayListenerDelegate.<init>(DisplayManagerGlobal.java:495)
       at android.hardware.display.DisplayManagerGlobal.registerDisplayListener(DisplayManagerGlobal.java:223)
       at android.hardware.display.DisplayManager.registerDisplayListener(DisplayManager.java:417)
       at com.captureprotection.CaptureProtectionModule.<init>(CaptureProtectionModule.java:37)
       at com.captureprotection.CaptureProtectionPackage.createNativeModules(CaptureProtectionPackage.java:19)
       at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42)
       at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:42)
       at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1456)
       at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1427)
       at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1338)
       at com.facebook.react.ReactInstanceManager.access$1200(ReactInstanceManager.java:136)
       at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:1108)
       at java.lang.Thread.run(Thread.java:784)

I will be sending a PR to fix this soon. Thanks for this great lib.

wn-na commented 1 year ago

@murat-mehmet Thanks to report issue for the previous version( < 10) Originally, this lib only going to support Android 10 and later, but take this opportunity to support earlier versions as well.

update this within a week with the following additions, thanks to report & PR