无法解决:de.hdodenhof:circleimageview:2.1.0

时间:2016-08-03 19:17:33

标签: android android-studio gradle

尝试添加两个maven存储库,但似乎无法解决这个问题 无法在stackoverflow上找到任何信息,并想知道在Gradle中解决依赖关系的标准方法是什么

Root build.gradle

buildscript {
    repositories {
        mavenCentral()
//        maven { url "https://mvnrepository.com/artifact/de.hdodenhof/circleimageview" }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'

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

模块build.gradle

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.3.0'
//    compile files('libs/CircleImageView-master/gradle/wrapper/gradle-wrapper.jar')
    compile 'de.hdodenhof:circleimageview:2.1.0'
}

无法解决:de.hdodenhof:circleimageview:2.1.0

2 个答案:

答案 0 :(得分:2)

我可以按照问题中的说明下载该依赖项。但是,作为参考,这是我的项目的build.gradle。我想你需要allprojects件。我遇到了依赖关系无法解决的问题。

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        mavenLocal()
    }

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

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

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        mavenLocal()
    }
}

另外需要注意:如果您要编译克隆的repo,那么就可以这样做

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(":CircleImageView-master:circleimageview")

    ...
}

settings.gradle将具有

include ':app', ':CircleImageView-master:circleimageview'

答案 1 :(得分:0)

您是否将compile依赖项添加到正确的Gradle文件中?确保compile 'de.hdodenhof:circleimageview:2.1.0'行位于dependencies {}块中,并且该块位于模块文件夹中的build.gradle文件中,而不是项目的根目录中。

如果没有帮助,请尝试从命令行运行./gradlew clean --refresh-dependencies