Rich-text Reply

ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

fingertricks 04-22-16
Accepted Solution

ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

When using the latest Android SDK (v1.4.2) and LiveVariables I see the following exception when calling get() on a LiveVariable<Boolean> when I'm in Editor or Preview mode:

 

 

java.lang.String cannot be cast to java.lang.Boolean

Steps to reproduce:

- Navigate to the screen containing the experiment,

- Switch between variants in the Optimizely dashboard (which changes the LiveVariable from true to false or vice versa)

- navigate back to the previous screen

- return to the experiment screen again

 

I can workaround the problem with the following wrapper around the call to the get(), but it shouldn't be necessary:

 

private static LiveVariable<Boolean> enableLogosVariable = Optimizely.booleanForKey(HYGIENE_LOGOS, false);

public
Boolean isExperimentVariantOn() {
try {
return enableLogosVariable.get();
} catch (ClassCastException e) {
return false;
}
}

 

 

Re: ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

tedroddy 04-22-16
 

Re: ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

fingertricks,

 

Thanks for bringing this to our attention. I was able to reproduce the crash using your repro steps. I'll file an internal bug report for this. 

 

Best,
Ted

Best,
Ted
Optimizely

Re: ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

Thanks for the quick response Ted. When this is fixed will there be a note in the Change Log?
tedroddy 04-25-16
 

Re: ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

Yep, the fix will be noted in the change log!

Best,
Ted
Best,
Ted
Optimizely

Re: ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

Although this bug isn't mentioned in the SDK's v1.5.0 release notes, at least not currently, it has been fixed in that release.

tedroddy 05-25-16
 

Re: ClassCastException when calling get() on a LiveVariable in Editor mode (Android)

Thanks @fingertricks. I think there were just too many bug fixes to list them all in the change log.
Best,
Ted
Optimizely