Search code examples
androidgradleandroid-gradle-pluginbuild.gradlebitbucket-api

Gradle DSL method not found: 'credentials()'


I am trying to add a dependency from my private BitBucket account using the BitBucket API following the accepted answer to this SO post.

My project root level build.gradle file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://bitbucket.org/api/2.0/repositories/{user}/{repo}/commit/{tag_num}'
        }
        credentials {
            username 'my_username'
            password 'my_password'
        }
    }
}

I get the following error:

Error:(21, 0) Gradle DSL method not found: 'credentials()'
Possible causes:
    - The project 'USPLibraryClerk' may be using a version of Gradle that does not contain the method.
    - The build file may be missing a Gradle plugin.

If I move the credentials {} to inside the maven {} block, nothing seems to update in terms of getting my repo.

maven {
    url 'https://bitbucket.org/api/2.0/repositories/{user}/{repo}/commit/{tag_num}'
    credentials {
        username 'my_username'
        password 'my_password'
    }
}

How do I fix this error message?


Solution

  • You can use somenthing like this:

    repositories {
            jcenter()
            maven {
                credentials {
                    username 'xxxx'
                    password 'xxxx'
                }
                url 'http://xxxxxxxx/repositories/releases/'
            }
      }
    

    Here the official doc.