build.gradle and project libs

I think you are specifying the path to your library project incorrectly. If I’m interpreting your project layout correctly the line should be the following:

compile project(':MyApp:libraries:projectLib')

When you start a project path with ‘:’ you are making an absolute path from the root project and then basically just writing a path with ‘:’ instead of “https://stackoverflow.com/”. In this case your projectLib module is in the directory MyProject/MyApp/libraries/projectLib, and MyProject is where your settings.gradle is, making it your root project. So swapping in colons for slashes gets you the line I wrote above.

You’ll need to modify your settings.gradle to include the full path as well:

include 'MyApp:libraries:projectLib'

Finally, if you want to save some typing for stuff like your repository configuration you can put it in an allproject block in your root project.

allprojects {
    repositories {
        mavenCentral()
    }
}

A lot of nice little tips like that covered in the multi-module docs.

Leave a Comment