Thu, 08 Sep 2022 08:21:57 GMT
Join the conversation at slack.cordova.io
Wed, 07 Sep 2022 19:21:08 GMT
@tvanzanten says
Has anyone successfully ran a Cordova Android app (using cordova-android 11.0.0) that has an <https://cordova.apache.org/docs/en/11.x/config_ref/images.html#android|adaptive app icon> and an <https://cordova.apache.org/docs/en/11.x/core/features/splashscreen/index.html#platform-splash-screen-image-configuration|adaptive icon splash screen>?
I was able to get an adaptive icon splash screen working, but when I try to move from a legacy app icon to an adaptive icon (not an animated one though), I get the following error:
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > Android resource linking failed ERROR:/Users/tylervanzanten/src/hypercision/rollcall/mobile/rollcall-mobile/platforms/android/app/src/main/res/values/themes.xml: AAPT: error: resource color/cdv_splashscreen_background (aka <http://com.rollcall.app:color/cdv_splashscreen_background|com.rollcall.app:color/cdv_splashscreen_background>) not found.``` To generate the XML file used for my splashscreen, I created a sample Android app in Android Studio and, following <https://developer.android.com/studio/write/image-asset-studio#create-adaptive|these instructions> for adding an icon to the sample app, I specified the Foreground Layer to be an SVG file of my desired splashscreen icon. Then I copied the newly generated file `MyApplication/app/src/main/res/drawable/ic_launcher_foreground.xml` into my Cordova app and renamed it `resources/android/splash/splashscreen.xml`. I did the same process to get an XML file of my desired app icon, but I renamed it `resources/android/icon/hclabs_foreground.xml`, and I also copied over PNG files from the sample Android app such as `MyApplication/app/src/main/res/mipmap-hdpi/hclabs_ic_launcher.png`. The legacy app icons used to be defined in my config.xml file like so: ```<platform name="android"> <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" /> <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" /> <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" /> ... </platform>``` My config.xml file currently looks this: ```<platform name="android"> <resource-file src="resources/android/colors.xml" target="/app/src/main/res/values/colors.xml" /> <icon background="@color/white_background" density="ldpi" foreground="resources/android/icon/hclabs_foreground.xml" src="resources/android/icon/ldpi/hclabs_ic_launcher.png" /> <icon background="@color/white_background" density="mdpi" foreground="resources/android/icon/hclabs_foreground.xml" src="resources/android/icon/mdpi/hclabs_ic_launcher.png" /> <icon background="@color/white_background" density="hdpi" foreground="resources/android/icon/hclabs_foreground.xml" src="resources/android/icon/hdpi/hclabs_ic_launcher.png" /> <icon background="@color/white_background" density="xhdpi" foreground="resources/android/icon/hclabs_foreground.xml" src="resources/android/icon/xhdpi/hclabs_ic_launcher.png" /> <icon background="@color/white_background" density="xxhdpi" foreground="resources/android/icon/hclabs_foreground.xml" src="resources/android/icon/xxhdpi/hclabs_ic_launcher.png" /> <icon background="@color/white_background" density="xxxhdpi" foreground="resources/android/icon/hclabs_foreground.xml" src="resources/android/icon/xxxhdpi/hclabs_ic_launcher.png" /> <preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/splash/splashscreen.xml" /> <preference name="AndroidWindowSplashScreenBackground" value="#FFFFFF" /> </platform>``` There is a PNG file at each of the specified paths (i.e. `resources/android/icon/xxhdpi/hclabs_ic_launcher.png`). And I have a file `resources/android/colors.xml` with the following content: ```<?xml version="1.0" encoding="utf-8"?> <resources> <color name="white_background">#FFFFFFFF</color> </resources>``` To get rid of the error (resource color/cdv_splashscreen_background (aka <http://com.rollcall.app:color/cdv_splashscreen_background|com.rollcall.app:color/cdv_splashscreen_background>) not found) I modified it like so: ```<?xml version="1.0" encoding="utf-8"?> <resources> <color name="white_background">#FFFFFFFF</color> </resources>``` But now I get this error when running `cordova run android -d`: ```Merging and updating files from [www, platforms/android/platform_www] to platforms/android/app/src/main/assets/www Wrote out android application name "RollCall" to /Users/tylervanzanten/src/hypercision/rollcall/mobile/rollcall-mobile/platforms/android/app/src/main/res/values/strings.xml Cannot set property 'text' of null TypeError: Cannot set property 'text' of null at updateProjectSplashScreenBackgroundColor (/Users/tylervanzanten/src/hypercision/rollcall/mobile/rollcall-mobile/node_modules/cordova-android/lib/prepare.js:484:68) at /Users/tylervanzanten/src/hypercision/rollcall/mobile/rollcall-mobile/node_modules/cordova-android/lib/prepare.js:392:13 at Array.forEach (<anonymous>) at updateProjectSplashScreen (/Users/tylervanzanten/src/hypercision/rollcall/mobile/rollcall-mobile/node_modules/cordova-android/lib/prepare.js:384:7) at updateProjectAccordingTo (/Users/tylervanzanten/src/hypercision/rollcall/mobile/rollcall-mobile/node_modules/cordova-android/lib/prepare.js:269:5) at /Users/tylervanzanten/src/hypercision/rollcall/mobile/rollcall-mobile/node_modules/cordova-android/lib/prepare.js:67:21 at async Promise.all (index 0)``` I am using Node v14.18.1 in case that matters.