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

时间:2016-06-09 09:20:19

标签: android android-studio gradle dependencies

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

  

无法解决:com.github.glomadrian:loadingballs1.1

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

注意:我发现post似乎回答了我的问题,但不幸的是我仍然遇到了问题。

图书馆提供了一个小教程:

  

将特定存储库添加到构建文件中:

他们的示例代码:

   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
}

我已经将maven存储库添加到我的构建文件中:

build.gradle(Project)

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'

}

build.gradle(Module:app)

Imports System.Xml
Imports System.Xml.Linq
Module Module1
    Const FILENAME As String = "c:\temp\test.xml"
    Sub Main()
        Dim doc As XDocument = XDocument.Load(FILENAME)

        Dim prices() As Decimal = doc.Descendants().Where(Function(x) x.Name.LocalName = "price").Select(Function(y) Decimal.Parse(CType(y, String).Replace("$", ""))).ToArray()
    End Sub

End Module

1 个答案:

答案 0 :(得分:2)

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

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

或模块: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'

}