killserver / react-native-screenshot-prevent

MIT License
103 stars 39 forks source link

v1.2.0 Crash App on Android #39

Open gillbeits opened 7 months ago

gillbeits commented 7 months ago

Stacktrace com.facebook.react.bridge.NativeArgumentsParseException: RNScreenshotPrevent.enableSecureView got 1 arguments, expected 0 at com.facebook.react.bridge.JavaMethodWrapper.invoke(Unknown Source) at com.facebook.react.bridge.JavaModuleWrapper.invoke(Unknown Source) at com.facebook.jni.NativeRunnable.run(Native Method) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(Unknown Source) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(Unknown Source) at java.lang.Thread.run(Thread.java:1012)

rafagouveia commented 7 months ago

same

rafagouveia commented 7 months ago

Argument Error in react-native-screenshot-prevent Package v1.2.0 with React Native 73.6 or Higher

Description: In addition to the issue with the react-native-screenshot-prevent package in version v1.2.0, I'm encountering difficulties when trying to compile my React Native application with version 73.6 or higher using the New Arch configuration enabled. The compilation fails during the process, adversely affecting the progress of my application development.

Steps to Reproduce:

Install the react-native-screenshot-prevent package in version v1.2.0 in a React Native project with version 73.6 or higher. Configure and use the RNScreenshotPrevent.enableSecureView function as documented. During the execution of the application, observe the com.facebook.react.bridge.NativeArgumentsParseException error indicating that RNScreenshotPrevent.enableSecureView received an incorrect number of arguments. Attempt to enable the New Arch configuration. Execute the application compilation process. Expected Behavior:

The RNScreenshotPrevent.enableSecureView function should be used correctly, without argument errors, according to the documentation provided by the package. The application should compile successfully, even with the New Arch configuration enabled. Current Behavior:

During the execution of the application, the com.facebook.react.bridge.NativeArgumentsParseException error occurs, indicating that RNScreenshotPrevent.enableSecureView received an incorrect number of arguments. The compilation of the application fails during the process, preventing the generation of the compiled application. Additional Information:

Version of the react-native-screenshot-prevent package: v1.2.0
React Native Version: 73.6 or higher
New Arch Configuration: enabled
Specific details about the compilation failure, if available (e.g., error messages, stack trace)
Other relevant dependencies and versions
This issue is creating a significant obstacle in the development of my application. Any assistance or guidance on how to resolve this issue would be greatly appreciated.
rafaelsmag commented 7 months ago

I just started using/testing the lib and I got the same issue, for Android the code inside enable() and enableSecureView() seems to do the same thing, so as a workaround I'm only calling RNScreenshotPrevent.enableSecureView() if the platform is iOS to avoid the issue.

RNScreenshotPrevent.enabled(enable);
Platform.OS === 'ios' && RNScreenshotPrevent.enableSecureView();
rafagouveia commented 7 months ago

I just started using/testing the lib and I got the same issue, for Android the code inside enable() and enableSecureView() seems to do the same thing, so as a workaround I'm only calling RNScreenshotPrevent.enableSecureView() if the platform is iOS to avoid the issue.

RNScreenshotPrevent.enabled(enable);
Platform.OS === 'ios' && RNScreenshotPrevent.enableSecureView();

PR #40: Pull Request Submitted for Fixing the Problem

I've opened a Pull Request to address the issue at hand. I'm hopeful that the maintainer will review and approve it promptly. This fix will allow us to resume using the application smoothly and in accordance with the official documentation. Thank you for your attention to this matter.

amalStorilabs commented 6 months ago

same issue here

rafagouveia commented 6 months ago

@amalStorilabs Unfortunately, the maintainer hasn't responded to this issue yet, but we already know why it happens. After the last update, which allows placing an image for the secureView (supported only for iOS), a treatment wasn't added to prevent sending this to the Java code, causing the app to break because the Java code isn't expecting a parameter. I sent a PR to fix this issue, which unfortunately hasn't been reviewed by the author yet. I hope we can get a response soon. For now, follow @rafaelsmag's steps:

Platform.OS === 'ios' && RNScreenshotPrevent.enableSecureView();
killserver commented 5 months ago

pls check 1.2.1 version

rafagouveia commented 5 months ago

pls check 1.2.1 version

solved for me