Gradle project builds before library subproject, resulting in resources not found


I have a main Android project which has a dependency declared for a submodule:

dependencies {
    compile project(':project-library')
    compile fileTree(dir: 'libs', include: '*.jar')

And settings.gradle:

include ':project-library'
project(':project-library').projectDir = new File('project-library')

There are no errors when I copy the library project as a separate project and build it. The library project has a ‘android-library’ applied, and main has ‘’.

But when I run the main project I get this order of tasks:

Gradle tasks [:generateDebugSources, :project-library:generateFullDebugSources]

Then the build stops with errors about missing resources from the library project.

Am I missing something?