简体   繁体   English

Android Studio,构建gradle未能找到依赖项

[英]Android studio , build gradle failed to find dependencies

I have some problems in android studio and gradle... First of all I should mention that I download IFixit android project which is open source and import some part of it in my project, but something is wrong. 我在android studio和gradle中有一些问题...首先,我要提一下,我下载了IFixit android项目 ,该项目是开源的,并将其一部分导入到我的项目中,但是出了点问题。 When I add dependencies in my project and building gradle cause error for Failng To Find !!! 当我在项目中添加依赖项并构建gradle时,导致无法查找错误! for example below is two of them : 例如下面是其中两个:

compile "com.github.chrisbanes.pulltorefresh:pulltorefresh:2.1.2"
compile 'com.marczych.androidsectionheaders:androidsectionheaders:1.0.0'

I solve some of the errors by changing the name but above files doesnt work at all!!! 我通过更改名称解决了一些错误,但是以上文件根本不起作用!!! something that is strange for me is that my build.gradle file use jcenter() repository but IFixit ones use mavenCentaral() and actually i don't know what is the difference !i add mavenCentral() to my repository but nothing happened ! 对我来说奇怪的是我的build.gradle文件使用jcenter()存储库,但是IFixit的文件使用mavenCentaral(),实际上我不知道有什么区别!我将mavenCentral()添加到我的存储库中,但是什么也没发生!

I change first link to : 我将第一个链接更改为:

compile "com.github.chrisbanes.pulltorefresh:library:2.1.1"

and gradle build succesfully but my activity class can not resolve import like this : 并成功建立gradle,但我的活动类无法像这样解决导入:

import com.handmark.pulltorefresh.library.PullToRefreshBase;

and doenst know the classes ! 并知道班级!

I should mention that i use android studio v0.8.6 and gradle:0.13.+ (2.1) and minimum required sdk for my project is 4.0 我应该提到我使用android studio v0.8.6和gradle:0.13。+(2.1),我的项目所需的最低SDK为4.0

Is there any way to solve my problem and import dependencies without error ? 有什么办法可以解决我的问题并正确导入依赖项? I will appreciate any suggestion ... thanks in advance ... 我将不胜感激任何建议...在此先感谢...

UPDATE (Solution): 更新(解决方案):

I solved the problem by adding below line into my repositories : 我通过在存储库中添加以下行来解决该问题:

maven {
  url 'https://raw.github.com/iFixit/ark/master/releases/'
}

You should try using the '+' symbol when you specify the version of the dependency you need, this will get you the "latest" version available. 指定所需依赖项的版本时,应尝试使用“ +”符号,这将为您提供可用的“最新”版本。

for instance 例如

compile "com.github.chrisbanes.pulltorefresh:library:2.+" would get you the latest 2.x version compile "com.github.chrisbanes.pulltorefresh:library:+" would get you the latest one availabe xx version compile "com.github.chrisbanes.pulltorefresh:library:2.+"将为您提供最新的2.x版本。 compile "com.github.chrisbanes.pulltorefresh:library:+"将为您提供最新的一个可用xx版本。

however this is not quite "recommended" for projects that are constantly updating repos with nightly builds since something unstable might come up and affect the project, but sometimes it might be "ok". 但是对于经常使用夜间版本更新仓库的项目,这不是“建议”,因为可能会出现不稳定的情况并影响到项目,但有时可能是“好的”。

Best. 最好。

Looking into the errors, number of things stand out: 调查错误,可以发现很多事情:

  1. com.handmark.pulltorefresh.library.PullToRefreshBase class is not in com.github.chrisbanes.pulltorefresh:library but in com.github.chrisbanes.pulltorefresh:sample . com.handmark.pulltorefresh.library.PullToRefreshBase类不在com.github.chrisbanes.pulltorefresh:librarycom.github.chrisbanes.pulltorefresh:sample
  2. There is no published version of 2.1.2 of pulltorefresh . 没有pulltorefresh的2.1.2的发行版本。 The latest is 2.1.1 . 最新的是2.1.1

Based on that, I'd propose you adding both com.github.chrisbanes.pulltorefresh:library and com.github.chrisbanes.pulltorefresh:library (and maybe com.github.chrisbanes.pulltorefresh:extras as well) to your dependencies, all of version 2.1.1. 基于此,我建议您将com.github.chrisbanes.pulltorefresh:librarycom.github.chrisbanes.pulltorefresh:library (也可能是com.github.chrisbanes.pulltorefresh:extras )添加到依赖项中,全部版本2.1.1。 Should probably do the trick. 应该可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM