Search code examples
androidgradlesoftware-distribution

Set up custom library repo in gradle


I uploaded my lib to bintray to the custom private repo (myRepoName), then tried to use it in another project.

But I need to upload it somehow to dsl methods, otherwise it says Gradle method not found myRepoName

How to do it?

buildscript {
  repositories {
    myRepoName { url "https://bintray.com/myRepo/sdk/repo" }
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
  }
}

Solution

  • At the moment you are using a custom name for the repository you are declaring. Instead you will have to call an existing method on RepositoryHandler, the underlying domain object for the repositories method. To fix the error message, you will have to use the method maven for a Maven-based repository.

    buildscript {
        repositories {
            maven { 
                name 'myRepoName'
                url 'https://bintray.com/myRepo/sdk/repo' 
            }
        }
    }
    

    Please also keep in mind that there's a difference between the repositories you define within the buildscript block and for repositories defined on the top-level of the build script. Please refer to the Gradle user guide for more information.