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?
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.
The mavenCentral() alias means that dependencies are fetched from the central Maven 2 repository.
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.
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/'
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With