在旧设备上安装Android“Error inflating class ImageView”?

时间:2016-09-03 17:59:33

标签: android

我有一个回收站视图,其中每个元素都有一个图像。有时候这是空白的,有时候会有一个占位符,有时会有通过毕加索检索到的图像。在模拟器和运行Marshmallow的两台设备上工作得非常好。在4.3和4.4.2上的两个设备上分别不工作(三星S3和Galaxy Tab 3 8.0)。我收到以下错误:

android.view.InflateException: Binary XML file line #103: Error inflating class ImageView
                                                                      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
                                                                      at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
                                                                      at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
                                                                      at com.rhls.directrepairs.AgentListViewAdapter.onCreateViewHolder(AgentListViewAdapter.java:43)
                                                                      at com.rhls.directrepairs.AgentListViewAdapter.onCreateViewHolder(AgentListViewAdapter.java:20)
                                                                      at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:5779)
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5003)
                                                                      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:4913)
                                                                      at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2029)
                                                                      at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1414)
                                                                      at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1377)
                                                                      at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:578)
                                                                      at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3260)
                                                                      at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3069)
                                                                      at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3518)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1076)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:131)
                                                                      at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
                                                                      at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1319)
                                                                      at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:817)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
                                                                      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
                                                                      at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
                                                                      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
                                                                      at android.widget.LinearLayout.onLayout(LinearLayout.java:1440)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
                                                                      at android.view.View.layout(View.java:15204)
                                                                      at android.view.ViewGroup.layout(ViewGroup.java:4793)
                                                                      at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2260)
                                                                      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2007)
                                                                      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
                                                                      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6364)
                                                                      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
                                                                      at android.view.Choreographer.doCallbacks(Choreographer.java:591)
                                                                      at android.view.Choreographer.doFrame(Choreographer.java:561)
                                                                      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
                                                                      at android.os.Handler.handleCallback(Handler.java:730)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                    at android.os.Loope

我目前无法完成这项工作。我已经尝试从XML中的src字段中删除占位符图像(一个可绘制的.png文件),但仍然会崩溃。关于为什么这不起作用的任何想法?

1 个答案:

答案 0 :(得分:1)

这可能是因为你在ImageView中使用矢量作为背景 看一下这个answer