Hello,
I'm the developer of react-native-flipper-databases plugin for React Native, which can be used to inspect React Native databases (such as watermelon-db) using the default Flipper client Databases plugin.
The plugin is essentially a "porting" to Typescript of the native Databases plugin available for Android.
One of the users of my module reported a strange issue when trying to run a RN app integrating my plugin on Android (on iOS it works just fine), the following error is thrown as soon as the plugin is registered using addPlugin from react-native-flipper package:
com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin cannot be cast to com.facebook.flipper.reactnative.FlipperReactNativeJavaScriptPlugin
(see panz3r/react-native-flipper-databases#1 for more details).
I suspect that this is due to the fact that my plugin uses the same ID as the native plugin (this way the Flipper client can re-use the included Databases plugin and no additional UI plugin is required) hence my question:
"Is it possibile to disable/exclude the default DatabasesFlipperPlugin and avoid the above native error?"
Thanks in advance for any answer/info related to this matter.
Flipper version: Version 0.60.0
React Native version: 0.63.2
react-native-flipper: 0.55.0
A bit hard to say much without code / reproduction, but it seems some wiring isn't set up right here. The addPlugin from react-native-plugin is used by the JavaScript bridge to register _JavaScript_ plugins. It should never be called from Java to register java plugins, which seems to be happening here. Rather, _native plugins_ should be registered on the flipperPlugin instance directly, like done over here: https://github.com/facebook/flipper/blob/master/react-native/ReactNativeFlipperExample/android/app/src/debug/java/com/reactnativeflipperexample/ReactNativeFlipper.java#L35
So I expect the problem is in the users java initialisation of Flipper in his debug folder, rather than being related to your plugin. But that deduction is entirely based on just the exception above, so for any more help a reproduction is needed :)
@mweststrate I'm the original reporter of the issue with the plugin by @panz3r
My ReactNativeFlipper.java file matches the example file you linked to. It is possible I have misconfigured something elsewhere although the other parts of Flipper were working correctly.
Looking at the full exception stack, I see getPlugin is called by registerPlugin which may support @panz3r 's theory that having the same id as the native database plugin is the issue. Here is the full stack I omitted in the original report:
Exception in native call
java.lang.ClassCastException: com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin cannot be cast to com.facebook.flipper.reactnative.FlipperReactNativeJavaScriptPlugin
at com.facebook.flipper.reactnative.FlipperReactNativeJavaScriptPluginManager.getPlugin(FlipperReactNativeJavaScriptPluginManager.java:141)
at com.facebook.flipper.reactnative.FlipperReactNativeJavaScriptPluginManager.registerPlugin(FlipperReactNativeJavaScriptPluginManager.java:64)
at com.facebook.flipper.reactnative.FlipperModule.registerPlugin(FlipperModule.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
at java.lang.Thread.run(Thread.java:761)
In that case it sounds like you should drop the line that loads the
original Flipper database plugin?
On Tue, 27 Oct 2020, 05:10 Chris Stranex, notifications@github.com wrote:
@mweststrate https://github.com/mweststrate I'm the original reporter
of the issue with the plugin by @panz3r https://github.com/panz3rMy ReactNativeFlipper.java file matches the example file you linked to.
It is possible I have misconfigured something elsewhere although the other
parts of Flipper were working correctly.Looking at the full exception stack, I see getPlugin is called by
registerPlugin which may support @panz3r https://github.com/panz3r 's
theory that having the same id as the native database plugin is the issue.
Here is the full stack I omitted in the original report:Exception in native call
java.lang.ClassCastException: com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin cannot be cast to com.facebook.flipper.reactnative.FlipperReactNativeJavaScriptPlugin
at com.facebook.flipper.reactnative.FlipperReactNativeJavaScriptPluginManager.getPlugin(FlipperReactNativeJavaScriptPluginManager.java:141)
at com.facebook.flipper.reactnative.FlipperReactNativeJavaScriptPluginManager.registerPlugin(FlipperReactNativeJavaScriptPluginManager.java:64)
at com.facebook.flipper.reactnative.FlipperModule.registerPlugin(FlipperModule.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:154)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
at java.lang.Thread.run(Thread.java:761)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/flipper/issues/1628#issuecomment-716985471,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAN4NBCSJ7Y2I6WM6UL6XVLSMZI5RANCNFSM4S6K65SQ
.
Okay, removing that line does let the app start with the only caveat that I can only see databases from this plugin although I guess that is to be expected
Hi @cstranex ,
I can confirm that excluding the native plugins does work, I updated the README for react-native-flipper-databases to explain the required setup on Android.
Thanks @mweststrate for your support, I think this issue can be closed.