question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Splash screen breaks build for SDK lower than v26

See original GitHub issue

Bug Report

Problem

What is expected to happen?

Build should go through successfully.

What does actually happen?

If minSdkVersion is set to 26, there’s no issue and the build goes through. However I get the following error if the minSdkVersion is set to lower than 26:

Task :app:processReleaseResources FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:app:processReleaseResources’. A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction Android resource linking failed ERROR:PATH_TO_APP\platforms\android\app\src\main\res\drawable\ic_cdv_splashscreen.xml: AAPT: error: <adaptive-icon> elements require a sdk version of at least 26.

Information

I upgraded from cordova-android 10.1.1 to 11.0.0, removed the cordova-plugin-splashscreen since it’s been deprecated and updated the implementation to use adaptive icons(generated adaptive icons through Android Studio and moved the .xml files in their place as described), removed old <splash> declarations from the config.xml, added <resource-file> declarations to add the adaptive icons and old splash screens to the /res folder as below.

    <preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/splash-new/mipmap-anydpi-v26/ic_splash.xml" />
    <preference name="AndroidWindowSplashScreenBackground" value="#ffffff" />

    <resource-file src="resources/android/splash-new/values/ic_splash_background.xml" target="app/src/main/res/values/ic_splash_background.xml"/>
    <resource-file src="resources/android/splash-new/mipmap-anydpi-v26/ic_splash.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_splash.xml"/>
    <resource-file src="resources/android/splash-new/mipmap-anydpi-v26/ic_splash_round.xml" target="app/src/main/res/mipmap-anydpi-v26/ic_splash_round.xml"/>
    <resource-file src="resources/android/splash-new/mipmap-hdpi/ic_splash.png" target="app/src/main/res/mipmap-hdpi-v26/ic_splash.png"/>
    <resource-file src="resources/android/splash-new/mipmap-hdpi/ic_splash_round.png" target="app/src/main/res/mipmap-hdpi-v26/ic_splash_round.png"/>
    <resource-file src="resources/android/splash-new/mipmap-hdpi/ic_splash_foreground.png" target="app/src/main/res/mipmap-hdpi-v26/ic_splash_foreground.png"/>
    <resource-file src="resources/android/splash-new/mipmap-mdpi/ic_splash.png" target="app/src/main/res/mipmap-mdpi-v26/ic_splash.png"/>
    <resource-file src="resources/android/splash-new/mipmap-mdpi/ic_splash_round.png" target="app/src/main/res/mipmap-mdpi-v26/ic_splash_round.png"/>
    <resource-file src="resources/android/splash-new/mipmap-mdpi/ic_splash_foreground.png" target="app/src/main/res/mipmap-mdpi-v26/ic_splash_foreground.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xhdpi/ic_splash.png" target="app/src/main/res/mipmap-xhdpi-v26/ic_splash.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xhdpi/ic_splash_round.png" target="app/src/main/res/mipmap-xhdpi-v26/ic_splash_round.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xhdpi/ic_splash_foreground.png" target="app/src/main/res/mipmap-xhdpi-v26/ic_splash_foreground.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xxhdpi/ic_splash.png" target="app/src/main/res/mipmap-xxhdpi-v26/ic_splash.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xxhdpi/ic_splash_round.png" target="app/src/main/res/mipmap-xxhdpi-v26/ic_splash_round.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xxhdpi/ic_splash_foreground.png" target="app/src/main/res/mipmap-xxhdpi-v26/ic_splash_foreground.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xxxhdpi/ic_splash.png" target="app/src/main/res/mipmap-xxxhdpi-v26/ic_splash.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xxxhdpi/ic_splash_round.png" target="app/src/main/res/mipmap-xxxhdpi-v26/ic_splash_round.png"/>
    <resource-file src="resources/android/splash-new/mipmap-xxxhdpi/ic_splash_foreground.png" target="app/src/main/res/mipmap-xxxhdpi-v26/ic_splash_foreground.png"/>
    <resource-file src="resources/android/splash/drawable-land-ldpi-screen.png" target="app/src/main/res/drawable-land-ldpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-land-mdpi-screen.png" target="app/src/main/res/drawable-land-mdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-land-hdpi-screen.png" target="app/src/main/res/drawable-land-hdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-land-xhdpi-screen.png" target="app/src/main/res/drawable-land-xhdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-land-xxhdpi-screen.png" target="app/src/main/res/drawable-land-xxhdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-land-xxxhdpi-screen.png" target="app/src/main/res/drawable-land-xxxhdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-port-ldpi-screen.png" target="app/src/main/res/drawable-port-ldpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-port-mdpi-screen.png" target="app/src/main/res/drawable-port-mdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-port-hdpi-screen.png" target="app/src/main/res/drawable-port-hdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-port-xhdpi-screen.png" target="app/src/main/res/drawable-port-xhdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-port-xxhdpi-screen.png" target="app/src/main/res/drawable-port-xxhdpi/screen.png"/>
    <resource-file src="resources/android/splash/drawable-port-xxxhdpi-screen.png" target="app/src/main/res/drawable-port-xxxhdpi/screen.png"/>

As far as I understood I shouldn’t need to move up the minSdkVersion from 22->26, and we wouldn’t want to either since it would affect many users. Are there some specific tasks to be done to be able to support the old splashscreens?

Command or Code

$ ionic cordova build android --prod --release

Environment, Platform, Device

Windows 10

Version information

$ ionic info

Ionic:

Ionic CLI : 6.19.0 (C:[REDACTED]\nvm\v16.13.0\node_modules@ionic\cli) Ionic Framework : @ionic/angular 5.5.5 ([REDACTED]\node_modules@ionic\angular) @angular-devkit/build-angular : 0.901.15 ([REDACTED]\node_modules@angular-devkit\build-angular) @angular-devkit/schematics : 9.1.15 ([REDACTED]\node_modules@angular-devkit\schematics) @angular/cli : 9.1.15 ([REDACTED]\node_modules@angular\cli) @ionic/angular-toolkit : 2.3.3 ([REDACTED]\node_modules@ionic\angular-toolkit)

Cordova:

Cordova CLI : 10.0.0 (cordova-lib@10.1.0) Cordova Platforms : android 11.0.0 Cordova Plugins : cordova-clipboard 1.3.0 “Clipboard” cordova-plugin-app-version 0.1.14 “AppVersion” cordova-plugin-apprate 1.7.2 “AppRate” cordova-plugin-device 2.1.0 “Device” cordova-plugin-dialogs 2.0.2 “Notification” cordova-plugin-firebasex 14.2.1 “Google Firebase Plugin” cordova-plugin-inappbrowser 5.0.0 “InAppBrowser” cordova-plugin-ionic-keyboard 2.2.0 “cordova-plugin-ionic-keyboard” cordova-plugin-ionic-webview 5.0.0 “cordova-plugin-ionic-webview” cordova-plugin-nativestorage 2.3.2 “NativeStorage” cordova-plugin-network-information 3.0.0 “Network Information” cordova-plugin-statusbar 3.0.0 “StatusBar” cordova-plugin-taptic-engine 2.2.0 “Taptic Engine” cordova-plugin-x-socialsharing 6.0.4 “SocialSharing” cordova-sqlite-storage 6.0.0 “Cordova SQLite storage plugin - cordova-sqlite-storage plugin version” es6-promise-plugin 4.2.2 “Promise” ionic-plugin-deeplinks 1.0.22 “Ionic Deeplink Plugin” onesignal-cordova-plugin 3.2.0 “OneSignal Push Notifications”

Utility:

cordova-res : 0.15.4 native-run : 1.7.1

System:

Android SDK Tools : 26.1.1 ([REDACTED]\AppData\Local\Android\Sdk) NodeJS : v16.13.0 (C:\Program Files\nodejs\node.exe) npm : 8.1.0 OS : Windows 10

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jcesarmobilecommented, Oct 11, 2022

closing since you solved your issue and was not related to cordova

0reactions
ludovictomlocommented, Oct 10, 2022

@jcesarmobile I was asking because of this mention, but it doesn’t say anything about adaptive icons actually, whoops 😃 image

@breautek I tested and can confirm that by using the xxxhdpi PNG I can get around the min SDK issue and the builds don’t throw the AAPT error anymore for minSdkVersion 22. I’ll leave in the adaptive icon artifacts until I’ll find a solution and will update this issue if I find something. Thanks for the feedback though!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android 12: splash screen is no longer displayed ... - GitHub
On Android API <31 my old SplashScreen is no longer displayed. The device shows always the new style. Is this the default behavior?...
Read more >
Migrate your existing splash screen implementation to Android ...
This guide is written using the compat library. If you choose to migrate using the SplashScreen API directly, on Android 11 and lower...
Read more >
Android Splash Screen API incorrect logo for API versions less ...
I'm trying to implement the new Splash ...
Read more >
Supporting Android v12+ Splash Screens in Xamarin.Forms
Android recently changed how splash screens work in Android v12.0 (API Level 31). Let's take a look at how to support it in...
Read more >
A Comprehensive Guide to Android 12's Splash Screen API
Android 12 came along and a new Splash Screen API was added. ... because it will only work on Android 12 and break...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found