Since I can't edit the AndroidManifest.xml and it would regenerate that code again, how can I fix this?
It very much sounds like you are editing the generated Manifest in the
gen/ folder instead.
If you make the changes to the 'regular' Manifest, it should work.
If you use the default Android Studio project structure, the one you need to open is