Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle plugin 'com.android.library' does not search in custom maven repositories

Here is how my application module 'app' build gradle looks like:

apply plugin: 'com.android.application'

repositories {
    maven { url 'http://localhost:8080/repository/internal/' }
}

...

dependencies {
    compile 'org.apache.httpcomponents:httpmime:4.2.3'
    compile 'com.testpackage.networking:networking:1.0.3'
}

and it works just fine. I'm trying to use same dependency in my library module named 'librarymodule'. Here is how its build.gradle looks like:

apply plugin: 'com.android.library'

repositories {
    maven {
        url 'http://localhost:8080/repository/internal/'
    }
}

...

dependencies {
    compile 'org.apache.httpcomponents:httpmime:4.2.3'
    compile 'com.testpackage.networking:networking:1.0.3'
}

The only difference is gradle plugin 'com.android.library' used here vs 'com.android.application' used in 'app' module.

Error:A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:_debugCompile'. Could not find com.testpackage.networking:networking:1.0.3. Searched in the following locations: https://jcenter.bintray.com/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom https://jcenter.bintray.com/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar file:/Users/myusername/Library/Android/sdk/extras/android/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom file:/Users/myusername/Library/Android/sdk/extras/android/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar file:/Users/myusername/Library/Android/sdk/extras/google/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom file:/Users/myusername/Library/Android/sdk/extras/google/m2repository/com/testpackage/networking/networking/1.0.3/networking-1.0.3.jar Required by: LibrariesApplication:app:unspecified > LibrariesApplication:librarymodule:unspecified

So, for some reason there is no http://localhost:8080/repository/internal/com/testpackage/networking/networking/1.0.3/networking-1.0.3.pom under Searched in the following locations list.

It's not only my repository problems. I can for example use

maven { url 'https://mint.splunk.com/gradle/' }

repository with dependency

compile 'com.splunk.mint:mint:4.1'

and still getting similar error

Does anyone knows how to fix that?

like image 974
Roman Avatar asked Jun 11 '15 12:06

Roman


People also ask

Can Gradle use Maven repositories?

Gradle can consume dependencies available in the local Maven repository. Declaring this repository is beneficial for teams that publish to the local Maven repository with one project and consume the artifacts by Gradle in another project.

What is mavenCentral () in Gradle?

The mavenCentral() alias means that dependencies are fetched from the central Maven 2 repository.

Where do I put Gradle dependencies?

Gradle declares dependencies on JAR files inside your project's module_name /libs/ directory (because Gradle reads paths relative to the build.gradle file). This declares a dependency on version 12.3 of the "app-magic" library, inside the "com.example.android" namespace group.


1 Answers

This is a bit strange but adding custom repository to 'allprojects' of root build.gradle actually worked!

allprojects {
    repositories {
        jcenter()

        maven {
            url 'http://localhost:8080/repository/internal/'
        }
    }
}
like image 163
Roman Avatar answered Jan 03 '23 15:01

Roman