add maven repository to build.gradle

后端 未结 5 1860
独厮守ぢ
独厮守ぢ 2020-11-30 19:30

I added a custom maven repository to build.gradle in Android Studio but the dependency is not being found

Maven repository and dependency



        
相关标签:
5条回答
  • 2020-11-30 19:42

    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.

    0 讨论(0)
  • 2020-11-30 19:45

    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.

    0 讨论(0)
  • 2020-11-30 19:48

    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.

    0 讨论(0)
  • 2020-11-30 20:03

    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()
    }
    
    0 讨论(0)
  • 2020-11-30 20:06

    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'
    
    0 讨论(0)
提交回复
热议问题