Manoj Prabhakar
Manoj Prabhakar

Reputation: 1016

Gradle fails to resolve dependency through Nexus but artifacts downloads in browser

Gradle fails to resolve dependency via Nexus Repository where as the artifacts are downloadable through browser. I have the following error

Error:Could not find ecj.jar (org.eclipse.jdt.core.compiler:ecj:4.6.1). Searched in the following locations: http://infynexus/nexus/content/groups/Manoj.P04/org/eclipse/jdt/core/compiler/ecj/4.6.1/ecj-4.6.1.jar

but this jar is downloadable in the browser Chrome Screenshot

build.gradle

buildscript {
    repositories {
        maven {
            credentials {
                username mavenUser
                password mavenPassword
            }
            url 'http://infynexus/nexus/content/groups/Manoj.P04/'
        }

    }


    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven {
            credentials {
                username mavenUser
                password mavenPassword
            }
            url 'infynexus/nexus/content/groups/Manoj.P04/'
        }

        task clean(type: Delete) {
            delete rootProject.buildDir
        }
    }
}

gradle.properties

org.gradle.jvmargs=-Xmx1536m

mavenUser=xxxx
mavenPassword=xxx

Upvotes: 3

Views: 4531

Answers (2)

TmTron
TmTron

Reputation: 19371

In my case refreshing the gradle dependencies worked.
e.g. I executed gradle clean --refresh-dependencies once. And then the builds worked normally again.

Details:

I got the same error-message as the original answer:

Could not resolve all files for configuration ':m15_android_lib:debugCompileClasspath'.
> Could not find constraint-layout-solver.jar (com.android.support.constraint:constraint-layout-solver:1.1.0).
  Searched in the following locations:
http://localhost:8081/repository/maven-public/com/android/support/constraint/constraint-layout-solver/1.1.0/constraint-layout-solver-1.1.0.jar

The Nexus Repository browser showed only the .pom file for that dependency, but not the .jar.
I could also download the .jar file from my local Nexus: e.g. entering the URL directly in Chrome.
But the gradle build still failed to resolve the dependency.

Just some thoughts, if this should happen again:

  • Maybe it's a problem in Nexus (since it shows only the pom but also has the jar): in this case we can try to:
    • Invalidate the caches of the Repository (and maybe the Repository Group) This can be done when you log-in as admin and go to Manage Repositories
    • Restart the Nexus service
  • I think it may be related to Gradle itself (since --refresh-dependencies resolved the issue). So maybe just stopping the gradle daemon (with : gradle --stop) is also enough.
  • If it is really related to Android Studio caching, we could also try to restart Android Studio or use File- Invalidate caches/restart.

Upvotes: 6

Manoj Prabhakar
Manoj Prabhakar

Reputation: 1016

There was some problem with Android Studio cache. I went to the following location:

C:\Users\manoj.p04\AppData\Local\Android\Sdk\tools\lib

and ecj-4.6.1.jar was present. I deleted the jar and resynched, everything works fine now..

Thanks

Upvotes: 0

Related Questions