After a lot of trial and error, I managed to make some headway on this. First off, I created an Adaptive Icon using Android Studio. Livecode.com has a really good guide on how to do this. Once I generated the assets, this created a new res
folder with the following contents:
C:\MyApplication\app\src\main\res>tree /f
Folder PATH listing for volume Windows
Volume serial number is E47A-1E3F
C:.
├───drawable
├───drawable-v24
│ ic_launcher_foreground.xml
│
├───layout
│ activity_main.xml
│
├───mipmap-anydpi-v26
│ ic_launcher.xml
│ ic_launcher_round.xml
│
├───mipmap-hdpi
│ ic_launcher.png
│ ic_launcher.webp
│ ic_launcher_foreground.png
│ ic_launcher_round.png
│ ic_launcher_round.webp
│
├───mipmap-mdpi
│ ic_launcher.png
│ ic_launcher.webp
│ ic_launcher_foreground.png
│ ic_launcher_round.png
│ ic_launcher_round.webp
│
├───mipmap-xhdpi
│ ic_launcher.png
│ ic_launcher.webp
│ ic_launcher_foreground.png
│ ic_launcher_round.png
│ ic_launcher_round.webp
│
├───mipmap-xxhdpi
│ ic_launcher.png
│ ic_launcher.webp
│ ic_launcher_foreground.png
│ ic_launcher_round.png
│ ic_launcher_round.webp
│
├───mipmap-xxxhdpi
│ ic_launcher.png
│ ic_launcher.webp
│ ic_launcher_foreground.png
│ ic_launcher_round.png
│ ic_launcher_round.webp
│
├───values
│ colors.xml
│ ic_launcher_background.xml
│ strings.xml
│ themes.xml
│
└───values-night
themes.xml
Next, I updated my Cordova project's config.xml
file, specifically the AndroidWindowSplashScreenAnimatedIcon property to point to the activity_main.xml file that's just been generated:
<platform name="android">
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/layout/activity_main.xml" />
</platform>
Finally, if you check out the activity_main.xml file, it'll have some markup in it referring to constraint layouts. If you build the app at this point, you may get an error like the following:
error: attribute layout_constraintBottom_toBottomOf (aka com.yjr.jinguantong:layout_constraintBottom_toBottomOf) not found.
It looks like your project is missing a dependency, which you can add by opening project.properties
and adding the following property:
cordova.system.library.2=com.android.support.constraint:constraint-layout:1.1.3
There's a bit more information found on this Github issue page - of course adding it to project.properties means if you delete your platforms folder, you will have to re-add it manually. I wasn't able to find a way to just simply add this dependency. I did get around it by deleting some of the constraint markup from the activity_main.xml file. My project builds with this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity">
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" />
</androidx.constraintlayout.widget.ConstraintLayout>
Hope that helps for anyone else who was struggling.
bengrah