You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I meet a null pointer exception when I am using this library.
Here is the failing stacktrace:
11-21 15:02:19.170 12985 12985 E AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.roughike.bottombar.BottomBar.resizeTabsToCorrectSizes(BottomBar.java:391)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.roughike.bottombar.BottomBar.onLayout(BottomBar.java:761)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.android.internal.policy.DecorView.onLayout(DecorView.java:755)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2429)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2149)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1306)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6579)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:683)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:619)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:751)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6316)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
It seems that you did not check whether the xml resource exists or not.
If the tabXmlResource(line 195) does not really exist, line 148 will not be executed. Hence, currentTabs will be null. When the method onLayout(line 756) is triggered by android framework, it will invoke resizeTabsToCorrectSizes will a null argument. Therefore, a NullPointerException will be triggered in line 391.
Cheers
The text was updated successfully, but these errors were encountered:
Hi,
I meet a null pointer exception when I am using this library.
Here is the failing stacktrace:
11-21 15:02:19.170 12985 12985 E AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.roughike.bottombar.BottomBar.resizeTabsToCorrectSizes(BottomBar.java:391)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.roughike.bottombar.BottomBar.onLayout(BottomBar.java:761)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1080)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1741)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.android.internal.policy.DecorView.onLayout(DecorView.java:755)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.View.layout(View.java:17572)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:5656)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2429)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2149)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1306)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6579)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:683)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:619)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:751)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.os.Looper.loop(Looper.java:154)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6316)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
11-21 15:02:19.170 12985 12985 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
It seems that you did not check whether the xml resource exists or not.
If the tabXmlResource(line 195) does not really exist, line 148 will not be executed. Hence, currentTabs will be null. When the method onLayout(line 756) is triggered by android framework, it will invoke resizeTabsToCorrectSizes will a null argument. Therefore, a NullPointerException will be triggered in line 391.
Cheers
The text was updated successfully, but these errors were encountered: