Why I am getting a ModuleVersionNotFoundException when using a custom repository with user/password when maven is working?


I am trying to use Gradle with an enterprise repository manage by nexus. The nexus repository is accessible via HTTPS with user auhtentication and work well with my ~/.m2/settings.xml configuration (see settings.xml at the end).

However I can’t get this repository working with my Gradle configuration. I tried both with using mavenLocal() or with a specific gradle repository section. In both situation I get a ModuleVersionNotFoundException Could not find com.google.android:support-v4:r12.

The same dependecy work well in a maven project.

Please find below my config details and thanks for Gradle: I am using Gradle 1.4 with Sonatype Nexus 2.3.0-04.

I configure gradlew with the following:

-Djavax.net.ssl.trustStore=trust.jks \
-Djavax.net.ssl.trustStoreType=jks \

My gradle config:

buildscript {
    repositories {
        //maven {
credentials {
   username 'user'
  password 'pwd'
            //url "https://dev/nexus/content/groups/public"
    dependencies {
        compile 'com.google.android:support-v4:r12'



Instead of ‘mavenLocal’, you should use a ‘maven’ repository with the correct URL.

Where did you get the trustStore setup from? Are you doing something similar for Maven? Have you tried to leave it out?

If you are using basic authentication, the ‘credentials’ block is the correct approach. I recommend to check the Gradle and Nexus logs to find out if it really is an authentication problem, and what exactly the problem is.

If you do have the dependency in the local Maven repo, and ‘mavenLocal()’ didn’t work either, then it’s probably not an authentication problem. For one thing, inside ‘buildscript.dependencies’ you can only add dependencies to the ‘classpath’ configuration; there is no ‘compile’ configuration. I’d be surprised if that didn’t give an error.

Last but not least, try to run with ‘–refresh-dependencies’ after making a change.

Thanks for your answer, I found my issue.

It was because I use subprojects and I configure the remote repository only in buildscript section.

To solve the issue, I added:

allprojects {
    // Add Buildscript repository
    rootProject.buildscript.repositories.each {