Binary XML file line #2: Error inflating
Posted 张玉宝
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Binary XML file line #2: Error inflating相关的知识,希望对你有一定的参考价值。
- 06-27 14:29:27.600: E/androidRuntime(6936): FATAL EXCEPTION: main
- 06-27 14:29:27.600: E/AndroidRuntime(6936): android.view.InflateException: Binary XML file line #2: Error inflating class
- com.example.FileListItem
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at com.example.filemanage.FileListAdapter.getView(FileListAdapter.java:51)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.AbsListView.obtainView(AbsListView.java:2033)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.ListView.measureHeightOfChildren(ListView.java:1244)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.ListView.onMeasure(ListView.java:1155)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.View.measure(View.java:12723)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.View.measure(View.java:12723)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.View.measure(View.java:12723)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.View.measure(View.java:12723)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.View.measure(View.java:12723)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2095)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.View.measure(View.java:12723)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1064)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.os.Handler.dispatchMessage(Handler.java:99)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.os.Looper.loop(Looper.java:137)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.app.ActivityThread.main(ActivityThread.java:4456)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at java.lang.reflect.Method.invokeNative(Native Method)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at java.lang.reflect.Method.invoke(Method.java:511)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at dalvik.system.NativeStart.main(Native Method)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): Caused by: java.lang.ClassNotFoundException: com.example.FileListItem
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
- 06-27 14:29:27.600: E/AndroidRuntime(6936): ... 33 more
如果报这个错误有可能是布局文件中有自定义View 记得修改自定义布局包名
像我这边就包名写错了,一直报错,com.example.filemanage包下找不到FileListItem这个类
<com.example.filemanage.FileListItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dip"
android:paddingBottom="5dip"
android:orientation="horizontal"
android:gravity="center_vertical">
以上是关于Binary XML file line #2: Error inflating的主要内容,如果未能解决你的问题,请参考以下文章
在测试类中膨胀 ViewBinding 时出错:Binary XML file line #38: Binary XML file line #38: Error inflating class &l
Binary XML file line #8 in 包名路经:layout/layout文件名字: Binary XML file line #8 in 包名路经:layout/layout文件名字
Binary XML file line #17<vector; tag requires viewportWidth ;0
Binary XML file line #17<vector; tag requires viewportWidth ;0
android.view.InflateException: Binary XML file line #7: Error inflating class(OOM)