android.view.inflateexception异常处理

今天试着写个实现android自带视频播放器VideoView的例子时报出了android.view.inflateexception异常:
04-20 09:11:52.583: ERROR/AndroidRuntime(417): FATAL EXCEPTION: main
04-20 09:11:52.583: ERROR/AndroidRuntime(417): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.video/com.android.video.video}: android.view.InflateException: Binary XML file line #8: Error inflating class videoview
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.os.Looper.loop(Looper.java:123)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at java.lang.reflect.Method.invokeNative(Native Method)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at java.lang.reflect.Method.invoke(Method.java:521)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at dalvik.system.NativeStart.main(Native Method)
04-20 09:11:52.583: ERROR/AndroidRuntime(417): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class videoview
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.Activity.setContentView(Activity.java:1647)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at com.android.video.video.onCreate(video.java:22)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     ... 11 more
04-20 09:11:52.583: ERROR/AndroidRuntime(417): Caused by: java.lang.ClassNotFoundException: android.view.videoview in loader dalvik.system.PathClassLoader[/data/app/com.android.video-1.apk]
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-20 09:11:52.583: ERROR/AndroidRuntime(417):     ... 20 more

 

google了下,试过好几种方法但都不对,又抛出了其他异常

再仔细检查了下

将/layout/main.xml重新看了下

发现标签写成videoview,是小写的

于是换成大写开头VideoView试了下,可以正常启动,不抛异常了

 

大汗。。。。

你可能感兴趣的:(android)