添加特定的存储库以构建文件

Add specific repository to build file

问题: 我想将 library 添加到我的项目中。当我添加依赖项时,我得到:

Failed to resolve: com.github.glomadrian:loadingballs1.1

问题:我如何更改我的 gradle 文件来解决问题?我认为这与添加存储库 maven 有关。如果是这样,我必须把它正确地放在哪里?

注意: 我找到了一个 似乎可以回答我的问题,但不幸的是我仍然遇到了问题。

图书馆给出小教程:

Add the specific repository to your build file:

他们的示例代码:

repositories {
    maven {
        url "https://jitpack.io"
    }
}

我已经像这样将 Maven 存储库添加到我的构建文件中:

build.gradle(项目)

   buildscript {
    repositories {
        jcenter()

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

        //Maven plugin
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

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

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle(模块:应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.stack.overflow"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    (...)
    compile 'com.github.glomadrian:loadingballs:1.1@aar'

}

是的,您需要将存储库添加到您的 gradle 配置中,或者在您的项目 build.gradle 中,如下所示:

allprojects {
    repositories {
        jcenter()
        maven {
            url "http://dl.bintray.com/glomadrian/maven"
        }
    }
}

或 module:app build.gradle 像这样:

apply plugin: 'com.android.application'

android {
    (... your config...)
}

repositories {
    maven {
        url "http://dl.bintray.com/glomadrian/maven"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    (... more dependencies ...)
    compile 'com.github.glomadrian:loadingballs:1.1@aar'

}