Splash screen breaks build for SDK lower than v26
See original GitHub issueBug 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:
- Created a year ago
- Comments:6 (4 by maintainers)
closing since you solved your issue and was not related to cordova
@jcesarmobile I was asking because of this mention, but it doesn’t say anything about adaptive icons actually, whoops 😃
@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!