使用android.support.design.widget.CoordinatorLayout获取android.view.InflateException:二进制XML文件行#2:错误膨胀类<unknown>

时间:2016-03-15 21:53:49

标签: android android-layout

当我使用android.support.design.widget.CoordinatorLayout时,上述错误导致引发:java.lang.reflect.InvocationTarg 。但是当我使用LinearLayout时它工作正常。有谁能解释为什么? logcat数据是: -

FATAL EXCEPTION: main
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime: Process:E/AndroidRuntime:android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.LayoutInflater.createView(LayoutInflater.java:620)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at accos.viewing.com.viewingtheaccos.ListBuiltups.ListAdapter.getView(ListAdapter.java:52)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.AbsListView.obtainView(AbsListView.java:2338)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.ListView.measureHeightOfChildren(ListView.java:1273)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.ListView.onMeasure(ListView.java:1182)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:824)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:500)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:610)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:78)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1132)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:675)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1621)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.LinearLayout.measureVertical(LinearLayout.java:742)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.LinearLayout.onMeasure(LinearLayout.java:607)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5379)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.widget.FrameLayout.onMeasure(FrameLayout.java:340)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2368)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.View.measure(View.java:16834)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2246)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1312)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1509)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1189)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6223)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.Choreographer.doCallbacks(Choreographer.java:591)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.Choreographer.doFrame(Choreographer.java:560)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:808)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:103)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:193)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5333)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
03-16 13:36:15.901 23048-23048/? E/AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(

1 个答案:

答案 0 :(得分:0)

打开gradle,添加这些依赖项(如果不存在),并将您的应用SDK定位到23。

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'