Problem
When an array of PickerColumns is given to Ti.UI.Picker.add() on Android, the app crashes. The same code given in the test case works properly on iOS and Mobileweb. Also to note, if the PickerColumns are given individually to the add() call, it works as expected. It is only when an array of PickerColumns is given to Picker.add() that the crash occurs.
test case
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
var picker = Ti.UI.createPicker({
top: 0,
useSpinner: true
});
var cols = [];
for (var c = 0; c < 2; c++) {
var col = Ti.UI.createPickerColumn();
for (var i = 0; i < 5; i++) {
col.addRow(Ti.UI.createPickerRow({
title: 'row ' + i
}));
}
cols.push(col);
}
picker.add(cols);
win.add(picker);
win.open();
adb logcat
E/AndroidRuntime( 9194): FATAL EXCEPTION: main
E/AndroidRuntime( 9194): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.appc.mcPicker/com.appc.mcPicker.McpickerActivity}: java.lang.NullPointerException
E/AndroidRuntime( 9194): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
E/AndroidRuntime( 9194): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
E/AndroidRuntime( 9194): at android.app.ActivityThread.access$600(ActivityThread.java:123)
E/AndroidRuntime( 9194): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
E/AndroidRuntime( 9194): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 9194): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 9194): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 9194): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 9194): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 9194): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 9194): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 9194): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 9194): Caused by: java.lang.NullPointerException
E/AndroidRuntime( 9194): at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
E/AndroidRuntime( 9194): at java.util.Arrays.asList(Arrays.java:154)
E/AndroidRuntime( 9194): at ti.modules.titanium.ui.widget.picker.TextWheelAdapter.<init>(TextWheelAdapter.java:28)
E/AndroidRuntime( 9194): at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.refreshNativeView(TiUISpinnerColumn.java:180)
E/AndroidRuntime( 9194): at ti.modules.titanium.ui.widget.picker.TiUISpinnerColumn.<init>(TiUISpinnerColumn.java:38)
E/AndroidRuntime( 9194): at ti.modules.titanium.ui.PickerColumnProxy.createView(PickerColumnProxy.java:218)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:423)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:411)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:446)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:431)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:411)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:446)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:431)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:411)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:525)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:204)
E/AndroidRuntime( 9194): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime( 9194): at org.appcelerator.kroll.common.TiMessenger.dispatchMessage(TiMessenger.java:364)
E/AndroidRuntime( 9194): at org.appcelerator.kroll.common.TiMessenger.dispatchPendingMessages(TiMessenger.java:349)
E/AndroidRuntime( 9194): at org.appcelerator.kroll.common.TiMessenger$2.getResult(TiMessenger.java:234)
E/AndroidRuntime( 9194): at org.appcelerator.kroll.common.TiMessenger.sendBlockingMessage(TiMessenger.java:261)
E/AndroidRuntime( 9194): at org.appcelerator.kroll.common.TiMessenger.sendBlockingRuntimeMessage(TiMessenger.java:186)
E/AndroidRuntime( 9194): at org.appcelerator.kroll.KrollProxy.fireSyncEvent(KrollProxy.java:638)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:435)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.TiLaunchActivity.onCreate(TiLaunchActivity.java:145)
E/AndroidRuntime( 9194): at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:97)
E/AndroidRuntime( 9194): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime( 9194): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
E/AndroidRuntime( 9194): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
E/AndroidRuntime( 9194): ... 11 more
W/ActivityManager(29799): Force finishing activity com.appc.mcPicker/.McpickerActivity
PR https://github.com/appcelerator/titanium_mobile/pull/3003
No app crash.Environment used for verification - Titanium SDK:3.0.0.v20121024144610 Titanium Studio:3.0.0.201210220122