当前位置: 首页 > 知识库问答 >
问题:

Android.content.res.resources$NotFoundException:资源不是可绘制的(颜色或路径):

慕容成文
2023-03-14

我创建了一个Android应用程序,在Android平台5.1或更新版本中运行时,它可以正常运行,但在较老的版本中,我有一个例外:

  05-12 14:59:59.080 18227-18227/com.example.mmido.myapplication1 E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.mmido.myapplication1, PID: 18227
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mmido.myapplication1/com.example.mmido.myapplication1.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class android.support.v7.widget.Toolbar
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2385)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2436)
        at android.app.ActivityThread.access$800(ActivityThread.java:157)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:5398)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class android.support.v7.widget.Toolbar
        at android.view.LayoutInflater.createView(LayoutInflater.java:620)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:745)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
        at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
        at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
        at com.example.mmido.myapplication1.MainActivity.onCreate(MainActivity.java:32)
        at android.app.Activity.performCreate(Activity.java:5264)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2349)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2436) 
        at android.app.ActivityThread.access$800(ActivityThread.java:157) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374) 
        at android.os.Handler.dispatchMessage(Handler.java:110) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:5398) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) 
        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:423)
        at android.view.LayoutInflater.createView(LayoutInflater.java:594)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) 
        at android.view.LayoutInflater.parseInclude(LayoutInflater.java:839) 
        at android.view.LayoutInflater.rInflate(LayoutIn..
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.example.mmido.b2b.MainActivity">

    <android.support.design.widget.AppBarLayoutaac
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@drawable/mr_details"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayoutaac>

    <include layout="@layout/country_content_main" />

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@android:drawable/ic_dialog_email" />

</android.support.design.widget.CoordinatorLayout>

共有1个答案

柳珂
2023-03-14

我看到当您将xml放在错误的可抽放文件夹中时,就会发生这种问题。例如,在drawable-v24中,所以它在API<21上崩溃

将xml从drawable-v24剪切到粘贴drawable文件夹,它可以工作

 类似资料: