Search code examples
androidfluttersplash-screen

Flutter Android Splash screen errors


I'm looking to simply added a splash screen to my Android app built in Flutter. I want a red screen with an image in the centre. I have the following in Android:

color.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name = "crimson">#D272638</color>
</resources> 

launch_background.xml:

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@color/crimson" />

    <!-- You can insert your own image assets here -->
    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/logo" />
    </item>
</layer-list>

My file structure is as follows:

enter image description here enter image description here

Every time I try run the app I get the following error:

Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource compilation failed
     path-to-app/android/app/src/main/res/values/colors.xml:3:5-43: AAPT: error: invalid color.

     path-to-app/build/app/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml: AAPT: error: file failed to compile.

Why would creating a color for a splash screen crash and app?


Solution

  • For the next soul that finds themselves stuck in this situation, the problem I experienced above was because I was using capital letters in my colors.xml file. Just make all the characters lower case and you are good to go.