移动开发:android编程中遇到的Caused by: android.view.InflateException: Binary XML file line #11: Erro错误的原因及解决办法

在很多时候都会遇到这样的问题

我在调用百度地图时就遇到了这样的问题

main.xml

<com.baidu.mapapi.map.mapView
        android:id="@+id/bmapsView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true" >
    </com.baidu.mapapi.map.mapView>
07-10 08:33:01.585: E/AndroidRuntime(470): FATAL EXCEPTION: main
07-10 08:33:01.585: E/AndroidRuntime(470): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.baidumapsample/com.example.baidumapsample.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class com.baidu.mapapi.map.mapView
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.os.Handler.dispatchMessage(Handler.java:99)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.os.Looper.loop(Looper.java:123)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.ActivityThread.main(ActivityThread.java:4627)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at java.lang.reflect.Method.invokeNative(Native Method)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at java.lang.reflect.Method.invoke(Method.java:521)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at dalvik.system.NativeStart.main(Native Method)
07-10 08:33:01.585: E/AndroidRuntime(470): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class com.baidu.mapapi.map.mapView
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.Activity.setContentView(Activity.java:1647)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at com.example.baidumapsample.MainActivity.onCreate(MainActivity.java:23)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-10 08:33:01.585: E/AndroidRuntime(470): 	... 11 more
07-10 08:33:01.585: E/AndroidRuntime(470): Caused by: java.lang.ClassNotFoundException: com.baidu.mapapi.map.mapView in loader dalvik.system.PathClassLoader[/data/app/com.example.baidumapsample-1.apk]
07-10 08:33:01.585: E/AndroidRuntime(470): 	at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.view.LayoutInflater.createView(LayoutInflater.java:466)
07-10 08:33:01.585: E/AndroidRuntime(470): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
07-10 08:33:01.585: E/AndroidRuntime(470): 	... 20 more


出现了以上错误


更改为:

mail.xml

 <com.baidu.mapapi.map.MapView
        android:id="@+id/bmapsView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true" >
    </com.baidu.mapapi.map.MapView>

就可以运行了,这里有两种可能一是没事填写前面正确的包名,例如 <MapView></MapView>

                            另外一种就是本例类名写错了,总之,出现这个错误的原因就是没有找到对应的类


运行效果:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值