【问题标题】:Access remote gradle dependency访问远程 gradle 依赖
【发布时间】:2015-10-29 02:35:47
【问题描述】:

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

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

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

无法解决:com.github.akashandroid90:imageletter:1.0

我已经关注thisthis 链接来进行我的回购。但现在我无法在 gradle 文件中访问它。

【问题讨论】:

    标签: android git maven android-gradle-plugin build.gradle


    【解决方案1】:

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

    阅读你应该使用的 github repo 中的文档。

    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'
    

    更多信息here

    【讨论】:

    • 我也曾一次又一次地尝试编译 'com.github.akashandroid90:image-letter-icon:1.0' 但我仍然遇到同样的错误。
    • 我也试过 jitpack 使用 compile 'com.github.akashandroid90:ImageLetterIcon:v1.0' as show on jitpack 但得到同样的错误
    • @AkashJain 'com.github.akashandroid90:ImageLetterIcon:v1.0' 确实有效,所以很可能 jitpack 存储库从 build.gradle 中丢失或者它在错误的位置。人们有时会错误地将它放在 buildscript 下。
    • 我犯了与将 lib 放入 buildscript 相同的错误。所以我进行了更改,但我再次无法使用 jitpack 使用它
    • 我也在 maven 和 jcenter 上进行了 repo,但在 gradle 中也无法访问它们
    猜你喜欢
    • 2015-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多