Leanplum / Leanplum-Android-SDK

Leanplum's integrated solution delivers meaningful engagement across messaging and the in-app experience.
https://www.leanplum.com
Apache License 2.0
46 stars 40 forks source link

ClassCastException when reading number variables #552

Closed MRezaNasirloo closed 1 year ago

MRezaNasirloo commented 1 year ago

Expected Behavior

Get an Integer or Double value from leanplum variable using

private val _variable: Var<Double/Int?> = Var.define("variable", null)

Actual Behavior

Crashing with an exception:

Fatal Exception: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Double

or

Fatal Exception: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer

This doesn't happen all time, most of the time it works

Steps to Reproduce the Problem

  1. Create a number on variable dashboard with the value of say 50
  2. private val _variable: Var<Double/Int?> = Var.define("variable", null)

Specifications

hborisoff commented 1 year ago

@MRezaNasirloo Can you provide the whole stacktrace?

Can you test using a specific default value (let say 0 for integer), because I noticed that the model behind Var cannot deduce the type of the variable correctly when you pass null as default value.

Thank you for your feedback.