Package Overlay and R does not exist when merging manifests of multiple build variants/flavours

Clash Royale CLAN TAG#URR8PPP
Package Overlay and R does not exist when merging manifests of multiple build variants/flavours
Whilst trying to set-up a demo flavour for my android studio project I encountered some problems with the manifest and the R file.
Problem 1

my build and manifest files are as follows:
build.gradle

AndroidManifest.xml (for main)

AndroidManifest.xml (for demoDebug variant)

of course when I do what the message says and remove the package declaration in the demoDebug variant manifest I get the following
Problem 2

This error also appears if I copy the package attribute from the main manifest and put it into the demoDebug one. Using applicationIdSuffix does not solve this problem either. At this point I'm baffled so any help would be much appreciated
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.