Cannot mutate the dependencies of configuration ':app:debugCompileClasspath' after the configuration was resolved. After a configuration has been observed, it should not be modified

Typically it happens because something is prematurely resolving some configuration somehow.
What the problem is in your specific case is hard to tell, especially as the exception is just the symptom, not the problem.

But most probably update AGP and use the new DSL might help: Cannot apply plugins to subprojects from within a settings plugin