那日了狗的上半年的兼容性问题,下半年来解决。

Posted 一葉知秋

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了那日了狗的上半年的兼容性问题,下半年来解决。相关的知识,希望对你有一定的参考价值。

  android机型繁多,在一款机型下适配成功。另一款机型却崩溃退出。而丢给你的却是这样一堆莫名其妙的异常。上头的臭骂,机型没有,如何是好?可是开发狗是狗,不是神。那怎么办呢?记录下这狗血的异常和解决办法。

07-01 09:33:08.663 3067-3067/com.test.tao E/AndroidRuntime: FATAL EXCEPTION: main
                                                              android.view.InflateException: Binary XML file line #13: Error inflating class <unknown>
                                                                  at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                                                                  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
                                                                  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
                                                                  at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
                                                                  at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
                                                                  at android.view.LayoutInflater.parseInclude(Native Method)
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                  at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method)
                                                                  at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631)
                                                                  at android.view.LayoutInflater.inflate(Native Method)
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                  at com.test.tao.utils.GlobalUtils.inflate(GlobalUtils.java:91)
                                                                  at com.test.tao.base.BaseFragment.onCreateView(BaseFragment.java:59)
                                                                  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974)
                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)
                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252)
                                                                  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742)
                                                                  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617)
                                                                  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
                                                                  at android.os.Handler.handleCallback(Handler.java:725)
                                                                  at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                  at android.os.Looper.loop(Looper.java:137)
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5069)
                                                                  at java.lang.reflect.Method.invokeNative(Native Method)
                                                                  at java.lang.reflect.Method.invoke(Method.java:511)
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
                                                                  at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132)
                                                                  at dalvik.system.NativeStart.main(Native Method)
                                                               Caused by: java.lang.reflect.InvocationTargetException
                                                                  at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                  at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                  at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                                  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 
                                                                  at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                  at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631) 
                                                                  at android.view.LayoutInflater.parseInclude(Native Method) 
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                                  at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                  at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631) 
                                                                  at android.view.LayoutInflater.inflate(Native Method) 
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                  at com.test.tao.utils.GlobalUtils.inflate(GlobalUtils.java:91) 
                                                                  at com.test.tao.base.BaseFragment.onCreateView(BaseFragment.java:59) 
                                                                  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) 
                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 
                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) 
                                                                  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742) 
                                                                  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) 
                                                                  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517) 
                                                                  at android.os.Handler.handleCallback(Handler.java:725) 
                                                                  at android.os.Handler.dispatchMessage(Handler.java:92) 
                                                                  at android.os.Looper.loop(Looper.java:137) 
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5069) 
                                                                  at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                  at java.lang.reflect.Method.invoke(Method.java:511) 
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
                                                                  at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) 
                                                                  at dalvik.system.NativeStart.main(Native Method) 
                                                               Caused by: java.lang.UnsupportedOperationException: Cant convert to dimension: type=0x1
                                                                  at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
                                                                  at android.content.res.XResources$XTypedArray.getDimensionPixelSize(XResources.java:945)
                                                                  at android.widget.TextView.<init>(TextView.java:916)
                                                                  at android.widget.TextView.<init>(TextView.java:578)
                                                                  at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                                  at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
                                                                  at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
                                                                  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) 
                                                                  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660) 
                                                                  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                                  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 
                                                                  at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                  at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631) 
                                                                  at android.view.LayoutInflater.parseInclude(Native Method) 
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 
                                                                  at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                                  at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) 
                                                                  at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:631) 
                                                                  at android.view.LayoutInflater.inflate(Native Method) 
                                                                  at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                  at com.test.tao.utils.GlobalUtils.inflate(GlobalUtils.java:91) 
                                                                  at com.test.tao.base.BaseFragment.onCreateView(BaseFragment.java:59) 
                                                                  at android.support.v4.app.Fragment.performCreateView(Fragment.java:1974) 
                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067) 
                                                                  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1252) 
                                                                  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:742) 
                                                                  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1617) 
                                                                  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517) 
                                                                  at android.os.Handler.handleCallback(Handler.java:725) 
                                                                  at android.os.Handler.dispatchMessage(Handler.java:92) 
                                                                  at android.os.Looper.loop(Looper.java:137) 
                                                                  at android.app.ActivityThread.main(ActivityThread.java:5069) 
                                                                  at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                  at java.lang.reflect.Method.invoke(Method.java:511) 
                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
                                                                  at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:132) 
                                                                  at dalvik.system.NativeStart.main(Native Method) 

  网上查了N多资料说的是values里面少了默认值。可是在一堆配置文件里面怎么把它找出来呢?一开始我是拒绝的,无从下手。相信不少做android开发的都会碰到这样的问题。这里说说开发狗是怎么解决这个问题的吧。

  碰到这样的现象主要体现在如下方面:

    1、别人的讥讽笑料,见惯不怪了。

    2、心绪低落,不开心;拉到会议室,被上头狗血淋头地骂一顿;内心只有呵呵...,该下班下班。

    3、来一杯红酒,该吃吃该喝喝。哦,对了,那都是上半年的事情了。

  当你碰到一个问题的时候,很多时候无论走路吃饭都会想着。无从下手,内心着实是有种无力感。然而想起当初学程序时的那个最简单的调试方法,错了找不着问题,删掉一部分一部分加进来测试不就OK了吗?

  上半年的bug,下半年解决。于是开启模拟器,将所有相关代码注释掉,把相关配置文件删掉。反复几次后,问题给定位出来了。网上说的问题没错,确实是由于value-xxx下定义了某个属性值,而values下没有默认值,导致不同机型下找不到默认值而导致app崩溃。好吧,问题定位到了,下面是具体解决办法。

  1、将values-XXX全部备份后删掉

  2、将报错的信息一个个添加回values

  造成这种情况的原因:

    1、开发狗是狗,不是神。

    2、在做第三方集成的时候由于一些资源文件冲突,没有整合到values文件夹下,被丢弃了。

以上是关于那日了狗的上半年的兼容性问题,下半年来解决。的主要内容,如果未能解决你的问题,请参考以下文章

To the end

网页打印控件 HttpPrinter 使用半年评测

网页打印控件 HttpPrinter 使用半年评测

出差(3~十七)

三面字节测试岗位,提前刷了半年的面试题(附答案)

2018下半年Java后端开发书单推荐