tidev / titanium-sdk

🚀 Native iOS and Android Apps with JavaScript
https://titaniumsdk.com/
Other
2.76k stars 1.21k forks source link

Android. TabGroup. NullPointerException #13195

Closed drauggres closed 2 years ago

drauggres commented 2 years ago

I have searched and made sure there are no existing issues for the issue I am filing

Description

java.lang.NullPointerException: Attempt to invoke virtual method 'android.app.Activity org.appcelerator.titanium.proxy.TiViewProxy.getActivity()' on a null object reference
  at ti.modules.titanium.ui.widget.tabgroup.TiUIAbstractTabGroup.selectTab(TiUIAbstractTabGroup.java:417)
  at ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup.selectTab(TiUIBottomNavigationTabGroup.java:444)
  at ti.modules.titanium.ui.widget.tabgroup.TiUIBottomNavigationTabGroup.onMenuItemClick(TiUIBottomNavigationTabGroup.java:420)
  at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:154)
  at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991)
  at com.google.android.material.bottomnavigation.BottomNavigationMenuView$1.onClick(BottomNavigationMenuView.java:124)
  at android.view.View.performClick(View.java:6724)
  at android.view.View.performClickInternal(View.java:6682)
  at android.view.View.access$3400(View.java:797)
  at android.view.View$PerformClick.run(View.java:26479)
  at android.os.Handler.handleCallback(Handler.java:873)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:233)
  at android.app.ActivityThread.main(ActivityThread.java:7225)
  at java.lang.reflect.Method.invoke(Method.java:-2)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:499)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:962)

Expected Behavior

Need to add if (this.proxy == null) return; guard to the top of the TiUIBottomNavigationTabGroup.onMenuItemClick method.

Actual behavior

App crash.

Reproducible sample

--

Steps to reproduce

--

Platform

Android

SDK version you are using

9.2.2 (should be reproducible on the master)

m1ga commented 2 years ago

https://github.com/appcelerator/titanium_mobile/pull/13199 I've added it at the last place in TiUIAbstractTabGroup where it runs getActivity()