自定义一个View,并在layout文件中进行部署,执行程序报以下错误:
- E/AndroidRuntime( 1292): FATAL EXCEPTION: main
- E/AndroidRuntime( 1292): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.raycommtech/com.raycommtech.HomecloudActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.AbsoluteLayout
- E/AndroidRuntime( 1292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
- E/AndroidRuntime( 1292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
- E/AndroidRuntime( 1292): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
- E/AndroidRuntime( 1292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
- E/AndroidRuntime( 1292): at android.os.Handler.dispatchMessage(Handler.java:99)
- E/AndroidRuntime( 1292): at android.os.Looper.loop(Looper.java:130)
- E/AndroidRuntime( 1292): at android.app.ActivityThread.main(ActivityThread.java:3683)
- E/AndroidRuntime( 1292): at java.lang.reflect.Method.invokeNative(Native Method)
- E/AndroidRuntime( 1292): at java.lang.reflect.Method.invoke(Method.java:507)
- E/AndroidRuntime( 1292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
- E/AndroidRuntime( 1292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
- E/AndroidRuntime( 1292): at dalvik.system.NativeStart.main(Native Method)
- E/AndroidRuntime( 1292): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.widget.AbsoluteLayout
- E/AndroidRuntime( 1292): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
- E/AndroidRuntime( 1292): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
- E/AndroidRuntime( 1292): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
- E/AndroidRuntime( 1292): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
- E/AndroidRuntime( 1292): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
- E/AndroidRuntime( 1292): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
- E/AndroidRuntime( 1292): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
- E/AndroidRuntime( 1292): at android.app.Activity.setContentView(Activity.java:1657)
- E/AndroidRuntime( 1292): at com.raycommtech.HomecloudActivity.onCreate(HomecloudActivity.java:92)
- E/AndroidRuntime( 1292): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
- E/AndroidRuntime( 1292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
- E/AndroidRuntime( 1292): ... 11 more
- E/AndroidRuntime( 1292): Caused by: java.lang.reflect.InvocationTargetException
- E/AndroidRuntime( 1292): at java.lang.reflect.Constructor.constructNative(Native Method)
- E/AndroidRuntime( 1292): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
- E/AndroidRuntime( 1292): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
- E/AndroidRuntime( 1292): ... 21 more
- E/AndroidRuntime( 1292): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f020020 a=-1 r=0x7f020020}
- E/AndroidRuntime( 1292): at android.content.res.Resources.loadDrawable(Resources.java:1681)
- E/AndroidRuntime( 1292): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
- E/AndroidRuntime( 1292): at android.view.View.<init>(View.java:1951)
- E/AndroidRuntime( 1292): at android.view.View.<init>(View.java:1899)
- E/AndroidRuntime( 1292): at android.view.ViewGroup.<init>(ViewGroup.java:286)
- E/AndroidRuntime( 1292): at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:47)
- E/AndroidRuntime( 1292): ... 24 more
开始以为是自定义的View重载的方法有问题,网上也查了很多关于自定义View方面引发的错误,还是木有得到解决。
仔细看看错误,就是没有找到资源文件,看看res/下面的资源文件,全放在drawable-mdpi/目录下,突然灵光一现,怀疑寻找的位置资源文件不存在,于是将drawable-mdpi/下的资源文件拷贝一份到drawable-ldpi/目录下,还是报上面的错误,再拷贝一份到drawable-hdpi/目录下,问题解决。
还有另外一种解决方法是在res/下建一目录drawable/,将drawable-mdpi/下所有的资源文件都拷贝到drawable/下即可
原文引用:http://blog.csdn.net/harry_helei/article/details/7265610
分享到:
相关推荐
第一次写博,如有不对,多多海涵。 背景: 最近学校Android课要求练习 第一行代码Android 上4.5新闻app实践,要使用到 fragment,recyclerview等控件,但按照书上按部就班写出来后,出现app无法打开情况。...
本篇文章将深入探讨如何在Android库路由XML中进行布局文件的处理,特别是关于在inflating布局时将标签从一个标签转移到另一个标签的操作。 首先,理解Android的布局inflation过程至关重要。Inflation是将XML布局...
android.view.InflateException: Binary XML file line #7: Error inflating class fragment异常 ( 2 ) android.support.v4.app.Fragment:可以兼容到1.6的版本,不能使用标签,需要在程序中通过add或者replace的...
Binary XML file line #2: Error inflating class android.support.constraint.ConstraintLayout 报错信息表明,这个问题是由于布局文件中的错误所引起的,具体来说,是由于 android.support.constraint....
google map v2中遇见xml里frment找不到问题 可以引入这个jar包就可以了 如Caused by: android.view.InflateException: Binary XML file line #3: Error inflating class fragment
Unable to start activity ComponentInfo{com.deyi.deyijia/com.deyi.deyijia.activity.PinterestActivity}: android.view.InflateException: Binary XML file line #157: Error inflating class android.support....
Unable to start activity ComponentInfo{com.deyi.deyijia/com.deyi.deyijia.activity.PinterestActivity}: android.view.InflateException: Binary XML file line #157: Error inflating class android.support....
在layout文件中使用自定义的View时遇到如下错误: 12-11 17:28:26.962: ERROR/AndroidRuntime(17121): android.view.InflateException: Binary XML file line #6: Error inflating class fish.apps.ipcall.controls...
android.view.InflateException: Binary XML file line #13: Error inflating class at android.view.LayoutInflater.createView(LayoutInflater.java:613) at com.android.internal.policy.impl.P
Java.lang.RuntimeException: Unable to start activity ComponentInfo{cm.test/cm.test.TestsActivity}:Android.view.InflateException: Binary XML file line #8: Error inflating class com.test.testview ...
其次,`android.view.InflateException: Binary XML file line #279: Error inflating class <unknown>` 异常通常出现在布局文件解析时,无法找到或实例化指定的视图类。这可能是因为以下原因: 1. **拼写错误或类名...
inflating: res/xml/literals.xml inflating: res/xml/references.xml extracting: resources.arsc However, at this point you have simply inflated compiled sources. If you tried to view AndroidManifest....