Bad check if dependency exists in mavenLocal()

I have repositories defined like this

allprojects {
      repositories {
          maven {
              url PUBLIC_REPO_URL
              credentials {
                  username NEXUS_USERNAME
                  password NEXUS_PASSWORD

So. Gradle should look first to the local maven repo and then download it from the our company repo if is not stored locally.

But it fail with

  • What went wrong: A problem occurred configuring project ‘:app’. > Artifact ‘’ not found.

Searched in the following locations:


I check the folder and android-styled-dialogs/1.1.2/ exist there already. But it is downloaded only .apklib version, no .aar version. If I delete whole directory, it works correctly. It looks that gradle simply check if android-styled-dialogs/1.1.2/android-styled-dialogs-1.1.2.pom exists and doesn’t check if really exist required type of dependency.

So. It looks like bug.

Hi Tomáš

I have filed GRADLE-3178 for this.

Note that you generally don’t need to have the ‘mavelLocal()’ repo in your Gradle build file - Gradle’s default caching should work just fine. So I’d usually strongly recommend not having it in there unless you really need it.

Sometimes people use the local maven cache as a sort of local cross-project integration repository when working on related projects - it you’re doing that and need ‘mavenLocal()’ in there, then put it at the bottom, so that Gradle can pick up all your other dependencies in a more normal way and just falls back to the maven repo for the locally-built stuff.


And Yes I agree. I only use maven often too, so I have most of dependencies already downloaded, so I thought that use mavenLocal() will speed up first build.

I’m also not happy that I will have every artifact twice on my computer, but it is not possible to configure gradle to use local maven repo as it’s own cache.

Just to clarify, Gradle won’t re-download the artifacts if it finds them in your local maven repo. This happens even when you don’t include ‘mavenLocal()’ in your list of repositories.

I’m not sure if I understand what you mean.

If I omit mavenLocal(), gradle will be downloaded all dependencies from the central to it’s own local cache repository. So everything will be downloaded again. If I use mavenLocal(), gradle will check local maven repository and take the dependency from here to it’s own cache. So the only benefit is that it will be a little bit faster.

No. If you omit mavenLocal(), Gradle will not download the dependencies again. Instead, it will check in your local maven repository for an artifact with a checksum matching that on the server, and copy it instead of downloading.

I don’t understand how to Gradle could check my local maven repository in .m2 folder if I omit mavenLocal(). I thinked that mavenLocal() is designed to force use local maven repository as described here

Thanks. Very interesting. So I can really skip the mavenLocal(), but where is difference if I will use it?

It’s only required if you’re using Maven to install an artifact locally, and then want to consume it with Gradle.

Thanks very much. It already make sense for me

I found that it is not problem only with mavenLocal().

Also if you have something like

maven { url “” } maven { url “” }

And first repository contain only

compile ‘com.viewpagerindicator:library:2.4.1@apklib’ and second one contain

compile ‘com.viewpagerindicator:library:2.4.1@aar’

You cann’t use use @aar completly, Gradle don’t check second one :frowning: