[TIMOB-18254] Using wrong value type should give informative error instead of crash (on Android)
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Open |
Resolution | Unresolved |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | TiAPI |
Labels | type, typeerror, value |
Reporter | Fokke Zandbergen |
Assignee | Unknown |
Created | 2014-12-17T15:48:51.000+0000 |
Updated | 2018-02-28T19:55:25.000+0000 |
Description
The following code crashes on Android with an IllegalArgumentException because the value needs to be a Boolean. But on iOS it works fine. I would expect a informative error in both cases and no crash on Android.
var w = Ti.UI.createWindow({backgroundColor:'red'});
var s = Ti.UI.createSwitch();
w.add(s);
w.open();
sw.value = 1;
Crash log:
12-17 16:41:59.294: E/AndroidRuntime(2017): FATAL EXCEPTION: main
12-17 16:41:59.294: E/AndroidRuntime(2017): java.lang.RuntimeException: Unable to start activity ComponentInfo{nl.fokkezb.tishadow/org.appcelerator.titanium.TiActivity}: java.lang.IllegalArgumentException: Unable to convert java.lang.Integer to boolean.
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.os.Handler.dispatchMessage(Handler.java:99)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.os.Looper.loop(Looper.java:137)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.ActivityThread.main(ActivityThread.java:5103)
12-17 16:41:59.294: E/AndroidRuntime(2017): at java.lang.reflect.Method.invokeNative(Native Method)
12-17 16:41:59.294: E/AndroidRuntime(2017): at java.lang.reflect.Method.invoke(Method.java:525)
12-17 16:41:59.294: E/AndroidRuntime(2017): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-17 16:41:59.294: E/AndroidRuntime(2017): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-17 16:41:59.294: E/AndroidRuntime(2017): at dalvik.system.NativeStart.main(Native Method)
12-17 16:41:59.294: E/AndroidRuntime(2017): Caused by: java.lang.IllegalArgumentException: Unable to convert java.lang.Integer to boolean.
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.util.TiConvert.toBoolean(TiConvert.java:357)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.util.TiConvert.toBoolean(TiConvert.java:383)
12-17 16:41:59.294: E/AndroidRuntime(2017): at ti.modules.titanium.ui.widget.TiUISwitch.updateButton(TiUISwitch.java:70)
12-17 16:41:59.294: E/AndroidRuntime(2017): at ti.modules.titanium.ui.widget.TiUISwitch.setStyle(TiUISwitch.java:176)
12-17 16:41:59.294: E/AndroidRuntime(2017): at ti.modules.titanium.ui.widget.TiUISwitch.propertyChanged(TiUISwitch.java:99)
12-17 16:41:59.294: E/AndroidRuntime(2017): at ti.modules.titanium.ui.widget.TiUISwitch.<init>(TiUISwitch.java:36)
12-17 16:41:59.294: E/AndroidRuntime(2017): at ti.modules.titanium.ui.SwitchProxy.createView(SwitchProxy.java:49)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:483)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:469)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:507)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:491)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:469)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:670)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.java:564)
12-17 16:41:59.294: E/AndroidRuntime(2017): at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:232)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:32)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:442)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:524)
12-17 16:41:59.294: E/AndroidRuntime(2017): at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.Activity.performCreate(Activity.java:5133)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-17 16:41:59.294: E/AndroidRuntime(2017): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
12-17 16:41:59.294: E/AndroidRuntime(2017): ... 11 more
Added related tickets