Gradle not able to resolve dependency from private github repository

I am trying to get an android library dependency from a private github repository but it is failing to resolve the dependency. This is what part of my build.gradle looks like:

repositories {
    mavenCentral()
    maven {
        url = 'https://github.com/github-username/github-project/raw/master'
        credentials {
            username 'my-username'
            password 'my-password'
        }
    }
}
   dependencies {
    compile 'com.example:library_project:0.0.1'
}

Am I doing something wrong here to authenticate to the private repo?

Does GitHub support HTTP basic authentication? That’s what you’ll get here.

Hi

I am facing the same issue. I am using Bit bucket for private repo. Bitbucket does provide http authentication. When I checked ~.gradle folder, even after giving the credentials it is not logging in and saving the full page. When I changed my repo from private to public the code started working. But I do not want to make my repo public. How to make gradle to use the login credentials passed?

Did you ever solve this issue?

I was able to solve it like http://stackoverflow.com/questions/25466407/gradle-build-failing-to-get-dependency-from-custom-maven-repository

Thanks for the quick reply :slight_smile: I have tried this solution but it does not work with the latest version of gradle 2.x. Was wondering if you have upgraded gradle at all and if so is it still able to access a private repo?

I tried, but did not work. so resorted to copying jar to libs folder :smiley:

Thats 1 step we don’t really want to do. I will keep digging and let you know if we come up with a solution. Thanks again …

Thanks :slight_smile: