我试图在接受this SO post的答案之后,使用BitBucket API从我的私有(private)BitBucket帐户添加依赖项。

我的项目根目录build.gradle文件:

// 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'
        }
    }
}

我收到以下错误:
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.

如果我将credentials {}移到maven {}块内,就获取回购而言似乎没有任何更新。
maven {
    url 'https://bitbucket.org/api/2.0/repositories/{user}/{repo}/commit/{tag_num}'
    credentials {
        username 'my_username'
        password 'my_password'
    }
}

如何解决此错误消息?

最佳答案

您可以使用类似以下的内容:

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

07-24 09:49
查看更多