Android 5.0低版本出现Error inflating class

     高版本没问题,就5.0的版本报错崩溃,查看日志: 

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: p.com.recordscreendemo, PID: 11069
    android.view.InflateException: Binary XML file line #7: Error inflating class 
        at android.view.LayoutInflater.createView(LayoutInflater.java:639)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:688)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747)

     第一个还看不出具体指向,顺着往下找:

 Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
        at android.view.LayoutInflater.createView(LayoutInflater.java:613)
        at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:688) 
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:747) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:812) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:510) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:420) 
        at android.view.LayoutInflater.inflate(LayoutInflater.java:371) 
        at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:437) 
        at p.com.recordscreendemo.activity.AllAppActivity.showDialog(AllAppActivity.java:146) 
        at p.com.recordscreendemo.activity.AllAppActivity.access$000(AllAppActivity.java:27) 
        at p.com.recordscreendemo.activity.AllAppActivity$1.onItemClick(AllAppActivity.java:86) 
        at android.widget.AdapterView.performItemClick(AdapterView.java:310) 
        at android.widget.AbsListView.performItemClick(AbsListView.java:1282) 
        at android.widget.AbsListView$PerformClick.run(AbsListView.java:3366) 
        at android.widget.AbsListView$3.run(AbsListView.java:4325) 
        at android.os.Handler.handleCallback(Handler.java:815) 
        at android.os.Handler.dispatchMessage(Handler.java:104) 
        at android.os.Looper.loop(Looper.java:192) 
        at android.app.ActivityThread.main(ActivityThread.java:5784) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:372) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850) 
     Caused by: android.content.res.Resources$NotFoundException: Resource "p.com.recordscreendemo:drawable/white_shape" (7f060066)  is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060066 a=-1 r=0x7f060066}
        at android.content.res.Resources.loadDrawableForCookie(Resources.java:2722)
        at android.content.res.Resources.loadDrawable(Resources.java:2646)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:749)

     最后4行是重点,指明了drawable可能出现了问题,当直接往drawable里放东西的时候,编辑器可能会把drawable文件放到drawable子系列文件夹,如下图的drawable-v24, 事实证明5.0版本的找不到drawable的子系列文件夹,只要把v24里的drawable文件放到drawable中,就解决了。

Android 5.0低版本出现Error inflating class_第1张图片

 

你可能感兴趣的:(android)