React-native-navigation: java.lang.ClassCastException when trying to push a new screen

Created on 10 Mar 2018  路  17Comments  路  Source: wix/react-native-navigation

03-10 06:31:59.239 26571 26597 W Bundle  : Key timestamp expected Double but value was a java.lang.Integer.  The default value 0.0 was returned.
03-10 06:31:59.239 26571 26597 W Bundle  : Attempt to cast generated internal exception:
03-10 06:31:59.239 26571 26597 W Bundle  : java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double
03-10 06:31:59.239 26571 26597 W Bundle  :  at android.os.BaseBundle.getDouble(BaseBundle.java:903)
03-10 06:31:59.239 26571 26597 W Bundle  :  at android.os.BaseBundle.getDouble(BaseBundle.java:885)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.reactnativenavigation.params.parsers.ScreenParamsParser.parse(ScreenParamsParser.java:32)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.reactnativenavigation.controllers.NavigationCommandsHandler.push(NavigationCommandsHandler.java:40)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.reactnativenavigation.bridge.NavigationReactModule.push(NavigationReactModule.java:182)
03-10 06:31:59.239 26571 26597 W Bundle  :  at java.lang.reflect.Method.invoke(Native Method)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
03-10 06:31:59.239 26571 26597 W Bundle  :  at android.os.Handler.handleCallback(Handler.java:739)
03-10 06:31:59.239 26571 26597 W Bundle  :  at android.os.Handler.dispatchMessage(Handler.java:95)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-10 06:31:59.239 26571 26597 W Bundle  :  at android.os.Looper.loop(Looper.java:148)
03-10 06:31:59.239 26571 26597 W Bundle  :  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
03-10 06:31:59.239 26571 26597 W Bundle  :  at java.lang.Thread.run(Thread.java:818)

This exception shows in the console when trying to push a new screen (android device only, works well on emulator).

It tries to cast from Integer to Double, but it fails:
https://github.com/wix/react-native-navigation/blob/e0a6ff2dad25c26eaa8ae1eacd3d2f185c5aebd5/android/app/src/main/java/com/reactnativenavigation/params/parsers/ScreenParamsParser.java#L32

Any suggestions?

Android looking for contributors

All 17 comments

@giladno hmm not sure why this would happen, but you can PR a getNumber method which will gracefully try to get double and fallback to integer

Actually ReadableMap of react native internally uses the HashMap where Key is String and value is Object
to if you pass 1 it will take Integer and if you pass 1.0 it will take double
so in that
int a = 1;
Integer b = 1; // unboxing requires Java 1.5+
double c = (double) a; // OK
Double d = (Double) b; // No way.
you can try
Object obj=param.get(KEY_TIMESTAMP)
if(obj instanceof Integer){ }
if(object instanceof Double){ }

+1, (even in android simulators)

+1 (on android A5 2017)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest version and report back. Thank you for your contributions.

I'm having this issue on Android

Same Here !! is that solution working @SudoPlz ? working with 1.44, I'm updating now to check if latests does the trick.

I haven't thoroughly tested @mojouy but yeah it should work. I can confirm soon though.

This is happening for me as well. Our app will successfully load but then will crash after a few seconds with the same error. Reproduceable on the emulator configuration attached, on version 1.1.458 (https://registry.yarnpkg.com/react-native-navigation/-/react-native-navigation-1.1.458.tgz#fe0ad5f7948768a82ebe69ed4bfc319c94ff9893)

screen shot 2018-06-15 at 2 28 11 pm

I had a typo on my view breaking and causing this error. double check guys just in case.

@mojouy Could you please elaborate what kind of typo you had?

I'm having this issue on Android too. I was working with the remote debugger and had changed some of the code and wanted to reload the application. As soon as I double pressed R to reload, the app crashed with the same exception.

I'm using the following versions of react-native and RNN:
"react-native": "0.56.0",
"react-native-navigation": "^1.1.478",

Having the same problem with those versions:

"react-native": "^0.56.0",
"react-native-navigation": "^1.1.479",

I do not understand what exactly is the proposed fix here. Could someone please elaborate?

Having the same problem too.
[email protected]
react-native 0.56
Would also like some insight into what might be causing it.
This is the code that triggers the error.
```
this.props.navigator.push({
screen: "myApp.IdeaScreen",
title: selGroup.name,
passProps: {
selectedKey: selGroup.key
},
animationType:'fade'
});

Yep, it's happening at every screen push...

Seems to only be happening to me when running on a device. No issues in emulator.

Was this page helpful?
0 / 5 - 0 ratings