Problem Description
Apps will crash when we set hint text to a numeric value in textbox after opening window.
Looks like error is from:
https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUIText.java#L233
Test Environment
Ti SDK 3.2.1.GA
Ti CLI 3.2.1
Android 4.4.2
Test Code
index.xml
<Alloy>
<Window class="container">
<Label id="label" top="30" onClick="doError">throw error</Label>
<Label id="label" top="10" onClick="doNoError">no error</Label>
<TextField id="txtField" hintText="123"/>
</Window>
</Alloy>
index.js
function doError(e) {
$.txtField.hintText=456;
}
function doNoError(e) {
$.txtField.hintText='789';
}
$.index.open();
Steps to reproduce:
Create new allow project 3.2.1.GA
Update test code to index.js and index.xml file
Launch in android; press label 'throw error'
Error Logs
[WARN] : dalvikvm: threadid=1: thread exiting with uncaught exception (group=0xa4c3d648)
[ERROR] : TiApplication: (main) [15493,15493] Sending event: exception on thread: main msg:java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String; Titanium 3.2.1,2014/02/06 17:03,991027b
[ERROR] : TiApplication: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
[ERROR] : TiApplication: at ti.modules.titanium.ui.widget.TiUIText.propertyChanged(TiUIText.java:233)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollPropertyChange.fireEvent(KrollPropertyChange.java:21)
[ERROR] : TiApplication: at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1059)
[ERROR] : TiApplication: at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:327)
[ERROR] : TiApplication: at ti.modules.titanium.ui.TextFieldProxy.handleMessage(TextFieldProxy.java:111)
[ERROR] : TiApplication: at android.os.Handler.dispatchMessage(Handler.java:95)
[ERROR] : TiApplication: at android.os.Looper.loop(Looper.java:137)
[ERROR] : TiApplication: at android.app.ActivityThread.main(ActivityThread.java:5103)
[ERROR] : TiApplication: at java.lang.reflect.Method.invokeNative(Native Method)
[ERROR] : TiApplication: at java.lang.reflect.Method.invoke(Method.java:525)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
[ERROR] : TiApplication: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
[ERROR] : TiApplication: at dalvik.system.NativeStart.main(Native Method)
Explanation of Error:
http://stackoverflow.com/questions/8973381/why-cannot-cast-integer-to-string-in-java
Test code:
1. Click on button, app should not crash
PR https://github.com/appcelerator/titanium_mobile/pull/5653 merged
Verified Fixed using : Mac :10.9.2 Appcelerator Studio, build: 3.3.0.201405011408 SDK - 3.3.0.v20140502133323 acs-1.0.14 alloy-1.4.0-dev npm-1.3.2 titanium-3.3.0-dev titanium-code-processor-1.1.1 Xcode :5.1.1 Using given code , no error has been found when hintText value is set to numeric value. Hence closing.