Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16549] Android: Crash when hintText value is numeric

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2014-05-01T17:28:24.000+0000
Affected Version/sRelease 3.2.1
Fix Version/s2014 Sprint 09, 2014 Sprint 09 SDK, Release 3.3.0
ComponentsAndroid
Labelsautomated, module_textfield, qe-closed-3.3.0, qe-testadded, supportTeam
ReporterMostafizur Rahman
AssigneeHieu Pham
Created2014-03-04T16:13:11.000+0000
Updated2017-12-07T23:15:28.000+0000

Description

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

Comments

  1. Hieu Pham 2014-04-30

    Test code:
       var text = Ti.UI.createTextField({hintText: 123});
       var win = Ti.UI.createWindow();
       var crash = Ti.UI.createButton({top: 0, title: 'click me!'});
       
       crash.addEventListener('click', function(e) {
       	text.hintText = 456;
       });
       win.add(crash);
       win.add(text);
       win.open();
       
    1. Click on button, app should not crash
  2. Vishal Duggal 2014-05-01

    PR https://github.com/appcelerator/titanium_mobile/pull/5653 merged
  3. Deepti Pandey 2014-05-05

    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.

JSON Source