title: android.content.res.Resources$NotFoundException: File res/drawable-v21/launch_background.xml
body: <p>Previously I was building and running a Flutter app fine. I don't remember making any change, but recently, I run into such errors while building and running the app on a smartphone through Android Studio:</p>
  <pre><code>Launching lib\main.dart on SM N900 in debug mode...
  Running Gradle task 'assembleDebug'...
  E/AndroidRuntime(12731): FATAL EXCEPTION: main
  E/AndroidRuntime(12731): Process: io.flutter.demo.gallery, PID: 12731
  E/AndroidRuntime(12731): java.lang.RuntimeException: Unable to start activity ComponentInfo{io.flutter.demo.gallery/io.flutter.demo.gallery.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable-v21/launch_background.xml from drawable resource ID #0x7f040000
  E/AndroidRuntime(12731):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693)
  E/AndroidRuntime(12731):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758)
  E/AndroidRuntime(12731):    at android.app.ActivityThread.access$900(ActivityThread.java:177)
  E/AndroidRuntime(12731):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448)
  E/AndroidRuntime(12731):    at android.os.Handler.dispatchMessage(Handler.java:102)
  E/AndroidRuntime(12731):    at android.os.Looper.loop(Looper.java:145)
  E/AndroidRuntime(12731):    at android.app.ActivityThread.main(ActivityThread.java:5942)
  E/AndroidRuntime(12731):    at java.lang.reflect.Method.invoke(Native Method)
  E/AndroidRuntime(12731):    at java.lang.reflect.Method.invoke(Method.java:372)
  E/AndroidRuntime(12731):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
  E/AndroidRuntime(12731):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
  E/AndroidRuntime(12731): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-v21/launch_background.xml from drawable resource ID #0x7f040000
  E/AndroidRuntime(12731):    at android.content.res.Resources.loadDrawableForCookie(Resources.java:3752)
  E/AndroidRuntime(12731):    at android.content.res.Resources.loadDrawable(Resources.java:3620)
  E/AndroidRuntime(12731):    at android.content.res.Resources.getDrawable(Resources.java:1852)
  E/AndroidRuntime(12731):    at android.content.res.Resources.getDrawable(Resources.java:1818)
  E/AndroidRuntime(12731):    at io.flutter.embedding.android.FlutterActivity.getSplashScreenFromManifest(FlutterActivity.java:495)
  E/AndroidRuntime(12731):    at io.flutter.embedding.android.FlutterActivity.provideSplashScreen(FlutterActivity.java:469)
  E/AndroidRuntime(12731):    at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onCreateView(FlutterActivityAndFragmentDelegate.java:301)
  E/AndroidRuntime(12731):    at io.flutter.embedding.android.FlutterActivity.createFlutterView(FlutterActivity.java:520)
  E/AndroidRuntime(12731):    at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:414)
  E/AndroidRuntime(12731):    at android.app.Activity.performCreate(Activity.java:6283)
  E/AndroidRuntime(12731):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
  E/AndroidRuntime(12731):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
  E/AndroidRuntime(12731):    ... 10 more
  E/AndroidRuntime(12731): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #4: &lt;item&gt; tag requires a 'drawable' attribute or child tag defining a drawable
  E/AndroidRuntime(12731):    at android.graphics.drawable.LayerDrawable.inflateLayers(LayerDrawable.java:202)
  E/AndroidRuntime(12731):    at android.graphics.drawable.LayerDrawable.inflate(LayerDrawable.java:147)
  E/AndroidRuntime(12731):    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1150)
  E/AndroidRuntime(12731):    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1063)
  E/AndroidRuntime(12731):    at android.content.res.Resources.loadDrawableForCookie(Resources.java:3736)
  E/AndroidRuntime(12731):    ... 21 more
  </code></pre>
  <p><strong>Flutter doctor</strong>
  The output of <code>flutter doctor -v</code> is:</p>
  <pre><code>&gt;flutter doctor -v
  [√] Flutter (Channel master, 1.24.0-8.0.pre.1, on Microsoft Windows [Version 10.0.19041.264], locale en-US)
      • Flutter version 1.24.0-8.0.pre.1 at C:\Users\m3\repos\flutter
      • Framework revision e444b1e3fa (5 weeks ago), 2020-10-30 00:41:52 -0400
      • Engine revision 99cc50dfff
      • Dart version 2.11.0 (build 2.11.0-266.0.dev)
  
  [√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
      • Android SDK at C:\Users\m3\AppData\Local\Android\sdk
      • Platform android-30, build-tools 30.0.1
      • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
      • All Android licenses accepted.
  
  [√] Chrome - develop for the web
      • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
  
  [√] Android Studio (version 4.0)
      • Android Studio at C:\Program Files\Android\Android Studio
      • Flutter plugin version 50.0.1
      • Dart plugin version 193.7547
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
  
  [√] Connected device (3 available)
      • SM N900 (mobile) • 4d00b6ae472d80eb • android-arm    • Android 5.0 (API 21)
      • Web Server (web) • web-server       • web-javascript • Flutter Tools
      • Chrome (web)     • chrome           • web-javascript • Google Chrome 87.0.4280.66
  
  • No issues found!
  
  </code></pre>
  <p>I just simply Git checkout master branch. Open Android Studio. Connect the Android smartphone device to computer through USB port. Click the green triangle button (Android Studio) to build and run the app on the device with Android 5.0. Error are thrown on terminal. I'm on Windows 10.</p>
  <p><strong>Note</strong>
  Such posts show that maybe the Gradle build system needs to be configured differently, not sure how:</p>
  <p><a href="https://stackoverflow.com/a/39419701/3405291">https://stackoverflow.com/a/39419701/3405291</a></p>
  <h3>Update</h3>
  <p>Android Studio <code>File &gt; Invalidate Caches / Restart...</code> did NOT resolve the issue.</p>
  <h3>Update</h3>
  <p>Building and running the app with Android 9 (API 28), the exception is resolved and the app is fine:</p>
  <pre><code>$ flutter doctor -v
  [√] Flutter (Channel master, 1.26.0-2.0.pre.401, on Microsoft Windows [Version 10.0.19041.264], locale en-US)
      • Flutter version 1.26.0-2.0.pre.401 at C:\Users\m3\repos\flutter
      • Framework revision da5a454d5c (11 hours ago), 2021-01-17 01:24:03 -0500
      • Engine revision 609036f2bf
      • Dart version 2.12.0 (build 2.12.0-236.0.dev)
  
  [√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
      • Android SDK at C:\Users\m3\AppData\Local\Android\sdk
      • Platform android-30, build-tools 30.0.1
      • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
      • All Android licenses accepted.
  
  [√] Chrome - develop for the web
      • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
  
  [√] Android Studio (version 4.0)
      • Android Studio at C:\Program Files\Android\Android Studio
      • Flutter plugin version 50.0.1
      • Dart plugin version 193.7547
      • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
  
  [√] Connected device (2 available)
      • SM A105F (mobile) • RF8M60PVD5F • android-arm    • Android 9 (API 28)
      • Chrome (web)      • chrome      • web-javascript • Google Chrome 87.0.4280.88
  
  • No issues found!
  </code></pre>
  <h3>Update</h3>
  <p>Implication so far is that the app runs fine with Android 9 (API 28) but throws the above-mentioned exception with Android 5.0 (API 21). Does anybody know what could be the problem cause? How could I possibly run the app on Android 5.0 (API 21)?</p>
  <h3>Update</h3>
  <p>This is relevant:</p>
  <p><a href="https://github.com/flutter/gallery/issues/383" rel="noreferrer">https://github.com/flutter/gallery/issues/383</a></p>
  <h3>Update</h3>
  <p>Also, this is relevant:</p>
  <p><a href="https://github.com/flutter/flutter/issues/73118" rel="noreferrer">https://github.com/flutter/flutter/issues/73118</a></p>