gpt4 book ai didi

android - AppBarLayout.onCreateDrawableState 空指针异常 : Attempt to get length of null array

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:22:44 25 4
gpt4 key购买 nike

我们在三星 6.0.1 设备上遇到了太多此类崩溃。我们甚至得到了具有相同操作系统版本的相同设备,但仍然无法自行复制。我们收到其他膨胀异常,可能它们是相关的。

这个问题有解决方法吗?

支持库版本 - 24.2.1

这是完整的堆栈跟踪:

Exception android.view.InflateException: Binary XML file line #21: Binary XML file line #2: Error inflating class android.support.design.widget.AppBarLayout
android.view.LayoutInflater.inflate (LayoutInflater.java:551)
android.view.LayoutInflater.inflate (LayoutInflater.java:429)
com.myapp.profile.ProfileFragment.onCreateView (ProfileFragment.java:163)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2080)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1108)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1290)
android.support.v4.app.BackStackRecord.run (BackStackRecord.java:801)
android.support.v4.app.FragmentManagerImpl.execSingleAction (FragmentManager.java:1638)
android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:679)
android.support.v4.app.FragmentPagerAdapter.finishUpdate (FragmentPagerAdapter.java:143)
android.support.v4.view.ViewPager.populate (ViewPager.java:1240)
android.support.v4.view.ViewPager.populate (ViewPager.java:1088)
android.support.v4.view.ViewPager.onMeasure (ViewPager.java:1614)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.support.design.widget.CoordinatorLayout.onMeasureChild (CoordinatorLayout.java:700)
android.support.design.widget.CoordinatorLayout.onMeasure (CoordinatorLayout.java:767)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
android.widget.LinearLayout.measureVertical (LinearLayout.java:747)
android.widget.LinearLayout.onMeasure (LinearLayout.java:629)
android.view.View.measure (View.java:20166)
com.sothree.slidinguppanel.SlidingUpPanelLayout.onMeasure (SlidingUpPanelLayout.java:804)
android.view.View.measure (View.java:20166)
android.support.v4.widget.DrawerLayout.onMeasure (DrawerLayout.java:1085)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.support.v7.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:135)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
android.widget.LinearLayout.measureVertical (LinearLayout.java:747)
android.widget.LinearLayout.onMeasure (LinearLayout.java:629)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
com.android.internal.policy.PhoneWindow$DecorView.onMeasure (PhoneWindow.java:3143)
android.view.View.measure (View.java:20166)
android.view.ViewRootImpl.performMeasure (ViewRootImpl.java:2644)
android.view.ViewRootImpl.measureHierarchy (ViewRootImpl.java:1599)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:1891)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1487)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:7450)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:920)
android.view.Choreographer.doCallbacks (Choreographer.java:695)
android.view.Choreographer.doFrame (Choreographer.java:631)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:906)
android.os.Handler.handleCallback (Handler.java:739)
android.os.Handler.dispatchMessage (Handler.java:95)
arrow_drop_down
Caused by android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.AppBarLayout
android.view.LayoutInflater.createView (LayoutInflater.java:657)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:776)
android.view.LayoutInflater.parseInclude (LayoutInflater.java:966)
android.view.LayoutInflater.rInflate (LayoutInflater.java:843)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.inflate (LayoutInflater.java:527)
android.view.LayoutInflater.inflate (LayoutInflater.java:429)
com.myapp.profile.ProfileFragment.onCreateView (ProfileFragment.java:163)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2080)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1108)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1290)
android.support.v4.app.BackStackRecord.run (BackStackRecord.java:801)
android.support.v4.app.FragmentManagerImpl.execSingleAction (FragmentManager.java:1638)
android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:679)
android.support.v4.app.FragmentPagerAdapter.finishUpdate (FragmentPagerAdapter.java:143)
android.support.v4.view.ViewPager.populate (ViewPager.java:1240)
android.support.v4.view.ViewPager.populate (ViewPager.java:1088)
android.support.v4.view.ViewPager.onMeasure (ViewPager.java:1614)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.support.design.widget.CoordinatorLayout.onMeasureChild (CoordinatorLayout.java:700)
android.support.design.widget.CoordinatorLayout.onMeasure (CoordinatorLayout.java:767)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
android.widget.LinearLayout.measureVertical (LinearLayout.java:747)
android.widget.LinearLayout.onMeasure (LinearLayout.java:629)
android.view.View.measure (View.java:20166)
com.sothree.slidinguppanel.SlidingUpPanelLayout.onMeasure (SlidingUpPanelLayout.java:804)
android.view.View.measure (View.java:20166)
android.support.v4.widget.DrawerLayout.onMeasure (DrawerLayout.java:1085)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.support.v7.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:135)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
android.widget.LinearLayout.measureVertical (LinearLayout.java:747)
android.widget.LinearLayout.onMeasure (LinearLayout.java:629)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
com.android.internal.policy.PhoneWindow$DecorView.onMeasure (PhoneWindow.java:3143)
android.view.View.measure (View.java:20166)
android.view.ViewRootImpl.performMeasure (ViewRootImpl.java:2644)
android.view.ViewRootImpl.measureHierarchy (ViewRootImpl.java:1599)
arrow_drop_down
Caused by java.lang.reflect.InvocationTargetException:
java.lang.reflect.Constructor.newInstance (Constructor.java)
android.view.LayoutInflater.createView (LayoutInflater.java:631)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:776)
android.view.LayoutInflater.parseInclude (LayoutInflater.java:966)
android.view.LayoutInflater.rInflate (LayoutInflater.java:843)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.inflate (LayoutInflater.java:527)
android.view.LayoutInflater.inflate (LayoutInflater.java:429)
com.myapp.profile.ProfileFragment.onCreateView (ProfileFragment.java:163)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2080)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1108)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1290)
android.support.v4.app.BackStackRecord.run (BackStackRecord.java:801)
android.support.v4.app.FragmentManagerImpl.execSingleAction (FragmentManager.java:1638)
android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:679)
android.support.v4.app.FragmentPagerAdapter.finishUpdate (FragmentPagerAdapter.java:143)
android.support.v4.view.ViewPager.populate (ViewPager.java:1240)
android.support.v4.view.ViewPager.populate (ViewPager.java:1088)
android.support.v4.view.ViewPager.onMeasure (ViewPager.java:1614)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.support.design.widget.CoordinatorLayout.onMeasureChild (CoordinatorLayout.java:700)
android.support.design.widget.CoordinatorLayout.onMeasure (CoordinatorLayout.java:767)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
android.widget.LinearLayout.measureVertical (LinearLayout.java:747)
android.widget.LinearLayout.onMeasure (LinearLayout.java:629)
android.view.View.measure (View.java:20166)
com.sothree.slidinguppanel.SlidingUpPanelLayout.onMeasure (SlidingUpPanelLayout.java:804)
android.view.View.measure (View.java:20166)
android.support.v4.widget.DrawerLayout.onMeasure (DrawerLayout.java:1085)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.support.v7.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:135)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
android.widget.LinearLayout.measureVertical (LinearLayout.java:747)
android.widget.LinearLayout.onMeasure (LinearLayout.java:629)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
com.android.internal.policy.PhoneWindow$DecorView.onMeasure (PhoneWindow.java:3143)
android.view.View.measure (View.java:20166)
android.view.ViewRootImpl.performMeasure (ViewRootImpl.java:2644)
arrow_drop_down
Caused by java.lang.NullPointerException: Attempt to get length of null array
android.support.design.widget.AppBarLayout.onCreateDrawableState (AppBarLayout.java:494)
android.view.View.getDrawableState (View.java:18365)
android.view.View.setBackgroundDrawable (View.java:18614)
android.view.View.setBackground (View.java:18551)
android.view.View.<init> (View.java:4621)
android.view.ViewGroup.<init> (ViewGroup.java:589)
android.widget.LinearLayout.<init> (LinearLayout.java:202)
android.widget.LinearLayout.<init> (LinearLayout.java:198)
android.widget.LinearLayout.<init> (LinearLayout.java:194)
android.support.design.widget.AppBarLayout.<init> (AppBarLayout.java:151)
java.lang.reflect.Constructor.newInstance (Constructor.java)
android.view.LayoutInflater.createView (LayoutInflater.java:631)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:776)
android.view.LayoutInflater.parseInclude (LayoutInflater.java:966)
android.view.LayoutInflater.rInflate (LayoutInflater.java:843)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.inflate (LayoutInflater.java:527)
android.view.LayoutInflater.inflate (LayoutInflater.java:429)
com.myapp.profile.ProfileFragment.onCreateView (ProfileFragment.java:163)
android.support.v4.app.Fragment.performCreateView (Fragment.java:2080)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1108)
android.support.v4.app.FragmentManagerImpl.moveToState (FragmentManager.java:1290)
android.support.v4.app.BackStackRecord.run (BackStackRecord.java:801)
android.support.v4.app.FragmentManagerImpl.execSingleAction (FragmentManager.java:1638)
android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss (BackStackRecord.java:679)
android.support.v4.app.FragmentPagerAdapter.finishUpdate (FragmentPagerAdapter.java:143)
android.support.v4.view.ViewPager.populate (ViewPager.java:1240)
android.support.v4.view.ViewPager.populate (ViewPager.java:1088)
android.support.v4.view.ViewPager.onMeasure (ViewPager.java:1614)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.support.design.widget.CoordinatorLayout.onMeasureChild (CoordinatorLayout.java:700)
android.support.design.widget.CoordinatorLayout.onMeasure (CoordinatorLayout.java:767)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.LinearLayout.measureChildBeforeLayout (LinearLayout.java:1464)
android.widget.LinearLayout.measureVertical (LinearLayout.java:747)
android.widget.LinearLayout.onMeasure (LinearLayout.java:629)
android.view.View.measure (View.java:20166)
com.sothree.slidinguppanel.SlidingUpPanelLayout.onMeasure (SlidingUpPanelLayout.java:804)
android.view.View.measure (View.java:20166)
android.support.v4.widget.DrawerLayout.onMeasure (DrawerLayout.java:1085)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.support.v7.widget.ContentFrameLayout.onMeasure (ContentFrameLayout.java:135)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)
android.view.ViewGroup.measureChildWithMargins (ViewGroup.java:6328)
android.widget.FrameLayout.onMeasure (FrameLayout.java:194)
android.view.View.measure (View.java:20166)

最佳答案

当 AppBarLayout 试图初始化它的滚动条时抛出这个异常 - 很可能你的 Activity 样式设置了默认的滚动条样式并且 AppBarLayout 继承了它。

最简单的解决方案是确保 AppBarLayout 永远不使用滚动条,只需按照以下步骤操作:

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">

<!--YOUR LAYOUT-->

</android.support.design.widget.AppBarLayout>

我很确定我没有在 Android 项目中看到针对此问题的正确错误报告,所以我想是时候报告了。

编辑

我已经创建了示例应用程序来重现此问题 - 您可以找到它 here .当您在具有 API22 的设备上启动应用 issue-254934 - AppBarLayout 配置均有效,对于 API23 及更高版本,其中一个会导致与您在此处报告的完全相同的异常。

编辑

Issue-254923已经修复,错误修复将在未来的版本中发布

关于android - AppBarLayout.onCreateDrawableState 空指针异常 : Attempt to get length of null array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40037140/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com