[ALOY-894] Android proxies throwing ClassCastException on non string attributes
DescriptionWhen passing custom arguments using the
- Todd Lindner 2013-12-07
When trying bleeding edge SDK builds (3.2.x or 3.3.x) I am also seeing additional ClassCastExceptions. This time on a normal
. Perhaps a related bug in alloy, not converting Strings to Boolean. java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean at org.appcelerator.titanium.view.TiUIView.registerForTouch(TiUIView.java:1457)
- Tony Lukasavage 2013-12-07 This is more developer error than it is Alloy or Android's fault. By nature, XML handles only strings in attributes. If a developer needs to use a value other than a string, they should be using TSS, which they should be using in the first place regardless. There are hacks I can put in Alloy to do type conversion based on attribute name, but they would be "improvements", not "bug fixes" as the expectation should be that any value specified in an XML attribute should be a string. I can start to assess some of these attributes and have Alloy do the conversion, but honestly, you should be using TSS to assign properties to your UI components and avoid this entirely.
- Todd Lindner 2013-12-10 I agree, its poor development practice. Just thought it might be a parity issue since it works on iOS but not Android. I just assumed some type juggling happens in the proxies (beyond Alloy) on iOS, but obviously not in Android as direct Java casting is used.
- Tim Poulsen 2014-01-16 This is probably a platform issue, not Alloy. Even in classic code, assigning a non-string value to a TextField/TextArea on Android will throw the class cast exception. iOS seems to cast values automatically.
- Tim Poulsen 2014-01-16 I've opened TIMOB-16207 demonstrating that this behavior is present in classic projects. Recommend closing this ticket.
- Tim Poulsen 2014-01-16 Because the cause is the underlying platform handling of data type casting, we're not going to add a workaround in Alloy. See the related TIMOB ticket opened to cover the platform issue.