I added a custom maven repository to build.gradle in Android Studio but the dependency is not being found
Maven repository and dependency
Android Studio Users:
If you want to use grade, go to http://search.maven.org/ and search for your maven repo. Then, click on the "latest version" and in the details page on the bottom left you will see "Gradle" where you can then copy/paste that link into your app's build.gradle.
After
apply plugin: 'com.android.application'
You should add this:
repositories {
mavenCentral()
maven {
url "https://repository-achartengine.forge.cloudbees.com/snapshot/"
}
}
@Benjamin explained the reason.
If you have a maven with authentication you can use:
repositories {
mavenCentral()
maven {
credentials {
username xxx
password xxx
}
url 'http://mymaven/xxxx/repositories/releases/'
}
}
It is important the order.
You will need to define the repository outside of buildscript
. The buildscript
configuration block only sets up the repositories and dependencies for the classpath of your build script but not your application.
You have to add repositories
to your build file. For maven repositories you have to prefix repository name with maven{}
repositories {
maven { url "http://maven.springframework.org/release" }
maven { url "http://maven.restlet.org" }
mavenCentral()
}
Add the maven repository outside the buildscript
configuration block of your main build.gradle
file as follows:
repositories {
maven {
url "https://github.com/jitsi/jitsi-maven-repository/raw/master/releases"
}
}
Make sure that you add them after the following:
apply plugin: 'com.android.application'