- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我们在三星 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/
我目前状态的视频,以便更好地了解我的情况: video RecyclerView 上面的所有东西都在 AppbarLayout 里面 具有类似行为的 reddit 应用示例: video 目标: 1-
我正在创建一个带有 header 的 RecyclerView,当您向上滚动 RecyclerView 时 header 会折叠。我可以通过下面的布局非常接近地实现这一点,使用透明的 AppBarLa
我有一个 AppBarLayout 和 NestedScrollView。我希望 NestedScrollView 每当它向下滚动时,AppBarLayout 也应该优雅地展开,而 NestedScr
我正在尝试获取 AppBarLayout 的布局参数,但出现此错误。 java.lang.ClassCastException: android.support.design.widget.Coord
我正在为我的应用程序实现自定义 header 。在 AppBarLayout 中,我使用工具栏和我的自定义布局(名为 CustomHeader)。 我的 CustomHeader 有左下角和右下角圆角
我是编程新手,我想添加一个设置菜单按钮。 就像图片上的一样,我的应用程序没有显示三点按钮。 MainActivity.java : public class MainActivity extends
我有一个带有 fragment 的 ViewPager,其中包含一个 RecyclerView。 CollapsingTollbarLayout 位于 ViewPager 之上。一切正常,除了在 Re
我想做这个, 在 Android Studio 的预览中看起来不错,但在运行时我得到这个 正如您在屏幕开头看到的那样,颜色是白色,我想添加我自己的颜色,在本例中为绿色。 最初它使用的是 Cordina
我正在使用此布局来尝试实现可折叠的应用栏。 android:theme="@style/ThemeOverlay.AppCompat.Dark"
所以我有一个带有 AppBarLayout 和 CollapsingToolbarLayout 的 CoordinatorLayout。这是展开(左图)和折叠(右图)时的样子 我遇到的第一个问题是,当
我尽量让红色布局滚动,这样他就隐藏了,TabLayout 就留在了最上面 我需要红色布局来为我填充圆形头像的高度。我尝试将TabLayout滚动到顶部,红色布局继续滚动隐藏? 无法发送图片,请点击链接
我正在尝试从顶部为 AppBarLayout 设置动画,就像 this 中的工具栏一样视频。 这是我的布局
我需要我的 AppBarLayout 具有透明背景。 当我将 AppBarLayout 的背景更改为具有 @null 或 @android:color/transparent 时,我在工具栏的边框处看
使用 AppBarLayout 时出错,我尝试了 Clean Project 和 Rebuild Project,但它们没有用。 运行程序没有问题。这是为什么? XML 文件:
我想要实现的结果与图片上的结果几乎相同,但没有折叠并且在工具栏文本下有选项卡布局。我使用 CollapsingTollbarLayout 完成了它,但如果我不希望它折叠,我认为这不是一个好方法。我应该
我在 CoordinatorLayout 和 RecyclerView 中使用 AppBarLayout、CollapsingToolbarLayout 创建了折叠透明搜索栏。让 recyclerVi
Android Google Play 应用如何在用户点击 AppBarlayout 时动态改变颜色? 我尝试了以下方法 tabLayout.setOnTabSelectedListener(new
在页面上的任意位置下拉(过度滚动)时,我一直在努力实现 AppBarLayout 的缩放效果。 期望效果示例: https://android-arsenal.com/details/1/4443 我
当我尝试为 AppBarLayout 设置一个特定的高度值时,阴影完全消失了。 这是错误还是预期的行为? 我使用的是设计库的 26.0.0 版。 最佳答案 设置属性动画
我在 AppBarLayout 中使用了 CollapsingToolbarLayout,用户可以使用 AppBarLayout 中的 setExpanded(boolean) 方法展开或折叠它。 问
我是一名优秀的程序员,十分优秀!