访问远程 gradle 依赖项

Access remote gradle dependency

第一次做远程仓库。但是我在访问它时遇到了一些问题。以下是我的 gradle 个文件:

root 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()
}
}

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

gradle 文件

 apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.0"

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

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.github.akashandroid90:imageletter:1.0'
}

每次同步代码时我都会遇到同样的错误

Failed to resolve: com.github.akashandroid90:imageletter:1.0

我已经按照 this and this link 来制作我的 repo。但是现在我无法在 gradle 文件中访问它。

你必须改变你的依赖。
compile 'com.github.akashandroid90:imageletter:1.0' 错误。

正在阅读您应该使用的 github 存储库中的文档。

dependencies {
    compile 'com.imageletter:ImageLetterIcon:1.0'
}

但是您可以在 jcenter repo.
中检查依赖关系 看了repo里的pom文件,对名字有点疑惑
应该是:

compile 'com.github.akashandroid90:image-letter-icon:1.0'

您可以使用另一种方式添加对 github 项目的依赖,使用 github 存储库和 jitpack plugin
在这种情况下,您必须将此 repo 添加到您的 build.gradle

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

和依赖项:

dependencies {
        compile 'com.github.User:Repo:Tag'
    }

你的情况是

compile 'com.github.akashandroid90:ImageLetterIcon:1.0'

更多信息