简体   繁体   中英

Gradle build failing to get dependency from custom maven repository

I have created a custom maven repo on BitBucket following the link . When trying to use the dependencies in my android project using Gradle I am getting following error

Executing tasks: [:app:compileDebugJava]

Configuration on demand is an incubating feature.
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
Checksum missing at https://bitbucket.org/test/maven-repo/raw/master/repository/com/test/com/testCommon/1.0/testCommon-1.0.pom.sha1 due to: For input string: "<!"
Download https://bitbucket.org/test/maven-repo/raw/master/repository/com/test/com/testCommon/1.0/testCommon-1.0.pom

[Fatal Error] testCommon-1.0.pom:2:10: Already seen doctype.

Checksum missing at https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-v4/20.0.0/support-v4-20.0.0.pom.sha1 due to: For input string: "<!"
Download https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-v4/20.0.0/support-v4-20.0.0.pom

[Fatal Error] support-v4-20.0.0.pom:2:10: Already seen doctype.

Checksum missing at https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0.pom.sha1 due to: For input string: "<!"
Download https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0.pom

[Fatal Error] support-annotations-20.0.0.pom:2:10: Already seen doctype.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve com.test.com:testCommon:1.0.
     Required by:
         SettingsAid:app:unspecified
      > Could not parse POM https://bitbucket.org/test/maven-repo/raw/master/repository/com/test/com/testCommon/1.0/testCommon-1.0.pom
         > Already seen doctype.

I have changed the link. But opening the link directly returns the checksum.

Below is my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'maven'
android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.test.sampleapp"
        minSdkVersion 11
        targetSdkVersion 19
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
repositories {
    mavenCentral()
    maven {
        credentials {
            username "test@gmail.com"
            password "test"
        }
        url "https://bitbucket.org/test/maven-repo/raw/master/repository/"
    }
}
dependencies {
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.test.com:testCommon:1.0'
    compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
}

I am not sure what I am doing wrong here. I have also followed this link . Can anybody help me in fixing this.

Update 1:

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?

Thanks.

I fixed the issue by changing repo path to :

"https://"+username+":"+password+"@bitbucket.org/test/maven-repo/raw/master/repository/"

UserName and password are set in gradle.properties .

我的团队和我使用Bitbucket REST API解决了它,你可以在这个答案中找到更多细节: https//stackoverflow.com/a/30117276/4877779

i used to struggle against this problem for three days. according to your code, here is my solution. hope that save your life.

  1. your maven url is wrong. please use the right api of bitbuckest.org. and the url format should be https://api.bitbucket.org/1.0/repositories/team-or-user-name/prject-name/raw/branch-name . example: https://api.bitbucket.org/1.0/repositories/yolonetltd/yolonet-mvn-repo/raw/releases/ . note that do not use api.bitbucket.org/2.0, use api.bitbucket.org/1.0!

     repositories { mavenCentral() maven { credentials { username "xxxxx" // note, not email, use login user name please! password "xxxxx" } url "https://api.bitbucket.org/1.0/repositories/test/maven-repo/raw/master" // note, use api 1.0, do not use api 2.0! } } 
  2. if your dependency is aar format, you should add @aar after the dependency description. dependencies closure should like below. otherwise gradle will throw dependency not found error.

     dependencies { ... compile 'com.test.com:testCommon:1.0@aar' ... } 
  3. make sure your remote bitbucket maven repository holds the complete files directory like below. otherwise gradle will also throw dependency not found error.

     | ├── com │ ├── as-gradle │ │ └── demo │ │ └── localrepo │ │ ├── 1.0.0 │ │ │ ├── localrepo-1.0.0.aar │ │ │ ├── localrepo-1.0.0.aar.md5 │ │ │ ├── localrepo-1.0.0.aar.sha1 │ │ │ ├── localrepo-1.0.0.pom │ │ │ ├── localrepo-1.0.0.pom.md5 │ │ │ └── localrepo-1.0.0.pom.sha1 │ │ ├── maven-metadata.xml │ │ ├── maven-metadata.xml.md5 │ │ └── maven-metadata.xml.sha1 
add   authentication {

            basic(BasicAuthentication)
        }

        maven {
            credentials {
                username ''
                password ''
            }
            authentication {
                basic(BasicAuthentication)
            }
            url "https://bitbucket.org/USER/REPO/raw/BRANCH/"
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM