2016-08-03 435 views
0

试图添加两个maven仓库,但似乎无法得到解决。
找不到计算器上的任何信息,并想知道什么是在摇篮解决依赖的标准方式无法解决:de.hdodenhof:circleimageview:2.1.0

根的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

回答

0

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

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

+0

是的,根gradle具有存储库,并且模块gradle具有依赖关系。我已更新了我的主帖。 我已经使用Android Studio中的干净版本,我相信它相当于gradlew clean,但只要我想清楚,就会尝试使用它。 –

+0

不,它不相似,因为'--refresh-dependencies'使Gradle缓存无效并强制再次下载所有依赖项。 –

+0

应该在Android Studio或外部运行 –

1

我可以下载该问题中写入的依赖关系。不过,作为参考,这里是我的项目的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() 
    } 
} 

额外的说明:如果你是编译克隆回购,你做这样的事情

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

    ... 
} 

凡settings.gradle将有

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

刚刚意识到问题与依赖关系无关,但与我的代理有关,因为我能够在连接到我的WiFi热点时编译依赖关系,而不是公司代理 –