android.view.InflateException 异常处理

今天遇见的这个异常真让我无语,所以我把它写下来提醒不在犯这样的错,报异常的文件我把它贴出来如下:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/frame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center" >
</FrameLayout>

运行后报以下错误:

07-03 08:03:49.757: ERROR/AndroidRuntime(531): FATAL EXCEPTION: main
07-03 08:03:49.757: ERROR/AndroidRuntime(531): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cff.birdfram.activity/com.cff.birdfram.activity.BirdframActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class FramLayout
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.os.Looper.loop(Looper.java:123)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.ActivityThread.main(ActivityThread.java:3683)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at java.lang.reflect.Method.invokeNative(Native Method)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at java.lang.reflect.Method.invoke(Method.java:507)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at dalvik.system.NativeStart.main(Native Method)

07-03 08:03:49.757: ERROR/AndroidRuntime(531): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class FramLayout
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.Activity.setContentView(Activity.java:1657)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at com.cff.birdfram.activity.BirdframActivity.onCreate(BirdframActivity.java:19)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     ... 11 more

07-03 08:03:49.757: ERROR/AndroidRuntime(531): Caused by: java.lang.ClassNotFoundException: android.view.FramLayout in loader dalvik.system.PathClassLoader[/data/app/com.cff.birdfram.activity-2.apk]
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.view.LayoutInflater.createView(LayoutInflater.java:471)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
07-03 08:03:49.757: ERROR/AndroidRuntime(531):     ... 19 more

解决办法:根据错误日志Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class FramLayout 发现在XML文件中“FrameLayout”拼写错误少写了一个e, 修改过后运行正常

你可能感兴趣的:(exception,android,xml,File,layout,Class)