NullPointer exception when creating a ButtonBar on Android

You must Login before you can answer or comment on any questions.

When I try to create a ButtonBar I get a NullPointer exception in the platform code:

%<--------------------

[TRACE] D/TiApplication( 1117): payload={"value":"thread_namemain\nthread_id1\nerror_msgjava.lang.NullPointerException\n<<<<<<<<<<<<<<< STACK TRACE >>>>>>>>>>>>>>>\norg.appcelerator.titanium.TiProxy.setModelListener(TiProxy.java:107)\norg.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:232)\norg.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:223)\norg.appcelerator.titanium.proxy.TiViewProxy.getView(TiViewProxy.java:206)\norg.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:239)\nti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:68)\nandroid.os.Handler.dispatchMessage(Handler.java:95)\nandroid.os.Looper.loop(Looper.java:123)\nandroid.app.ActivityThread.main(ActivityThread.java:4627)\njava.lang.reflect.Method.invokeNative(Native Method)\njava.lang.reflect.Method.invoke(Method.java:521)\ncom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)\ncom.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)\ndalvik.system.NativeStart.main(Native Method)\n"} [TRACE] E/AndroidRuntime( 1117): FATAL EXCEPTION: main [TRACE] E/AndroidRuntime( 1117): java.lang.NullPointerException [TRACE] E/AndroidRuntime( 1117): at org.appcelerator.titanium.TiProxy.setModelListener(TiProxy.java:107) [TRACE] E/AndroidRuntime( 1117): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:232) [TRACE] E/AndroidRuntime( 1117): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:223) [TRACE] E/AndroidRuntime( 1117): at org.appcelerator.titanium.proxy.TiViewProxy.getView(TiViewProxy.java:206) [TRACE] E/AndroidRuntime( 1117): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:239) [TRACE] E/AndroidRuntime( 1117): at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:68) [TRACE] E/AndroidRuntime( 1117): at android.os.Handler.dispatchMessage(Handler.java:95) [TRACE] E/AndroidRuntime( 1117): at android.os.Looper.loop(Looper.java:123) [TRACE] E/AndroidRuntime( 1117): at android.app.ActivityThread.main(ActivityThread.java:4627) [TRACE] E/AndroidRuntime( 1117): at java.lang.reflect.Method.invokeNative(Native Method) [TRACE] E/AndroidRuntime( 1117): at java.lang.reflect.Method.invoke(Method.java:521) [TRACE] E/AndroidRuntime( 1117): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) [TRACE] E/AndroidRuntime( 1117): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) [TRACE] E/AndroidRuntime( 1117): at dalvik.system.NativeStart.main(Native Method) [TRACE] W/ActivityManager( 60): Force finishing activity com.tester/ti.modules.titanium.ui.TiTabActivity [TRACE] W/ActivityManager( 60): Activity pause timeout for HistoryRecord{43f46240 com.tester/ti.modules.titanium.ui.TiTabActivity} [TRACE] I/TiAnalyticsSvc( 1117): (Thread-10) [1354,3065] Sending 2 analytics events. [TRACE] D/dalvikvm( 1117): GC_FOR_MALLOC freed 5465 objects / 387288 bytes in 93ms [TRACE] D/dalvikvm( 1117): GC_FOR_MALLOC freed 1598 objects / 88728 bytes in 110ms [TRACE] W/TiAnalyticsSvc( 1117): (Thread-10) [2318,5383] Stopping Analytics Service [TRACE] W/ActivityManager( 60): Launch timeout has expired, giving up wake lock! [TRACE] W/ActivityManager( 60): Activity idle timeout for HistoryRecord{43f46240 com.tester/ti.modules.titanium.ui.TiTabActivity} [TRACE] W/ActivityManager( 60): Activity idle timeout for HistoryRecord{43e56790 com.tester/.TesterActivity} [TRACE] D/dalvikvm( 115): GC_EXPLICIT freed 860 objects / 47840 bytes in 96ms [TRACE] W/ActivityManager( 60): Activity destroy timeout for HistoryRecord{43f46240 com.tester/ti.modules.titanium.ui.TiTabActivity} [TRACE] I/Process ( 1117): Sending signal. PID: 1117 SIG: 9 [TRACE] I/ActivityManager( 60): Process com.tester (pid 1117) has died.

%<--------------------

code in app.js

// this sets the background color of the master UIView (when there are no windows/tab groups on it) Titanium.UI.setBackgroundColor('#000');

// create tab group var tabGroup = Titanium.UI.createTabGroup();

// // create base UI tab and root window // var win1 = Titanium.UI.createWindow({
title:'Tab 1', backgroundColor:'#fff' }); var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png', title:'Tab 1', window:win1 });

tabGroup.addTab(tab1);

var bb1 = Titanium.UI.createButtonBar({ labels:['One', 'Two', 'Three'], backgroundColor:'#336699', top:50, height:25, width:200 }); win1.add(bb1);

// open tab group tabGroup.open();

— asked 4 years ago by Daniel Goergen
1 Comment
  • This is still not working in 1.5.1 :

    [TRACE] W/dalvikvm( 1009): threadid=1: thread exiting with uncaught exception (group=0x4001d800) [TRACE] E/TiUncaughtHandler( 1009): (main) [734,1897] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 1.5.1,2010/12/16 16:25,6bbb92 [TRACE] E/TiUncaughtHandler( 1009): java.lang.NullPointerException [TRACE] E/TiUncaughtHandler( 1009): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:365) [TRACE] E/TiUncaughtHandler( 1009): at org.appcelerator.titanium.proxy.TiViewProxy.getView(TiViewProxy.java:348) [TRACE] E/TiUncaughtHandler( 1009): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:377) [TRACE] E/TiUncaughtHandler( 1009): at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:64) [TRACE] E/TiUncaughtHandler( 1009): at android.os.Handler.dispatchMessage(Handler.java:95) [TRACE] E/TiUncaughtHandler( 1009): at android.os.Looper.loop(Looper.java:123) [TRACE] E/TiUncaughtHandler( 1009): at android.app.ActivityThread.main(ActivityThread.java:4627) [TRACE] E/TiUncaughtHandler( 1009): at java.lang.reflect.Method.invokeNative(Native Method) [TRACE] E/TiUncaughtHandler( 1009): at java.lang.reflect.Method.invoke(Method.java:521) [TRACE] E/TiUncaughtHandler( 1009): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) [TRACE] E/TiUncaughtHandler( 1009): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) [TRACE] E/TiUncaughtHandler( 1009): at dalvik.system.NativeStart.main(Native Method) [TRACE] D/TiApplication( 1009): (main) [38,1935] Analytics Event: type=ti.crash [TRACE] D/TiApplication( 1009): event=ti.crash [TRACE] D/TiApplication( 1009): timestamp=2011-01-28T12:24:54.738+0100 [TRACE] D/TiApplication( 1009): mid=9774d56d682e549c [TRACE] D/TiApplication( 1009): sid=c8950e33-9a72-45dc-b482-5d46b408e7f2 [TRACE] D/TiApplication( 1009): aguid=dd00864a-56b9-4ed6-8e54-c39b29c777c2 [TRACE] D/TiApplication( 1009): isJSON=true [TRACE] D/TiApplication( 1009): payload={"value":"thread_namemain\nthread_id1\nerror_msgjava.lang.NullPointerException\nti_version1.5.1,2010\/12\/16 16:25,6bbb92\n<<<<<<<<<<<<<<< STACK TRACE >>>>>>>>>>>>>>>\norg.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:365)\norg.appcelerator.titanium.proxy.TiViewProxy.getView(TiViewProxy.java:348)\norg.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:377)\nti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:64)\nandroid.os.Handler.dispatchMessage(Handler.java:95)\nandroid.os.Looper.loop(Looper.java:123)\nandroid.app.ActivityThread.main(ActivityThread.java:4627)\njava.lang.reflect.Method.invokeNative(Native Method)\njava.lang.reflect.Method.invoke(Method.java:521)\ncom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)\ncom.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)\ndalvik.system.NativeStart.main(Native Method)\n"} [TRACE] E/AndroidRuntime( 1009): FATAL EXCEPTION: main [TRACE] E/AndroidRuntime( 1009): java.lang.NullPointerException [TRACE] E/AndroidRuntime( 1009): at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:365) [TRACE] E/AndroidRuntime( 1009): at org.appcelerator.titanium.proxy.TiViewProxy.getView(TiViewProxy.java:348) [TRACE] E/AndroidRuntime( 1009): at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:377) [TRACE] E/AndroidRuntime( 1009): at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:64) [TRACE] E/AndroidRuntime( 1009): at android.os.Handler.dispatchMessage(Handler.java:95) [TRACE] E/AndroidRuntime( 1009): at android.os.Looper.loop(Looper.java:123) [TRACE] E/AndroidRuntime( 1009): at android.app.ActivityThread.main(ActivityThread.java:4627) [TRACE] E/AndroidRuntime( 1009): at java.lang.reflect.Method.invokeNative(Native Method) [TRACE] E/AndroidRuntime( 1009): at java.lang.reflect.Method.invoke(Method.java:521) [TRACE] E/AndroidRuntime( 1009): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) [TRACE] E/AndroidRuntime( 1009): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) [TRACE] E/AndroidRuntime( 1009): at dalvik.system.NativeStart.main(Native Method)

    — commented 4 years ago by Tomaž Dobrišek

2 Answers

Android does not support the concept of a button bar (along with some other controls). So you need to fake one as in Joe's answer.

On the button bar docs page, note the upper right only has an apple icon and not an android icon as well. That is the (somewhat obscure) indication it is only supported on iOS,

Your Answer

Think you can help? Login to answer this question!