What I found which fixed this problem when I hit it was to add the following to my AndroidManifest.xml file:
<application
android:name=".VariantApp"
where "VariantApp" is the name of the class that extends android.app.Application in my project.
In my case, at least, I had added a dependency on Koin for dependency injection and that caused the issue to appear.