Multi-Project Error: Cannot change dependencies of configuration 'lib:default' after it has been included in dependency resolution

I’m using Gradle Wrapper 3.1, with Android Studio 2.2 and Kotlin 1.0.3

I recently started adding modules to my project (Kotlin likes modules instead of packages for visibility). Here is my structure:

Project
----myapp (android application)
----lib (android library)
----commons (android library)

myapp has a compile project(‘:lib:) dependency and lib has a compile project(’:commons’) dependency. When I try to sync or build I get the following error:

Error:A problem occurred configuring project ‘:lib’.

Cannot change dependencies of configuration ‘:lib:default’ after it has been included in dependency resolution.