【问题标题】:Gradle could not resolve dependency from artifactoryGradle 无法解决来自工件的依赖
【发布时间】:2013-12-01 21:38:35
【问题描述】:

我正在尝试构建一个 android-library (MyLib1),它依赖于 gradle 和 jenkins 中的另一个 android-library (MyLib2)。我有点绝望,因为我认为我的 gradle 文件和设置都还可以。

我成功地将第一个 android-library 发布到 artifactory。在 artifactory 中,我可以看到以下依赖声明:

compile(group: 'MyGroup', name: 'MyLib1', version: '1.0', ext: 'aar')

我将此依赖声明粘贴到我的第二个 build.gradle 中:

buildscript {
  repositories {
    maven { url "http://localhost:8081/artifactory/myvirtualrepository" }
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.6.+'
    classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.2.0')
  }
}
(...)
dependencies {
  compile (group: 'MyGroup', name: 'MyLib1', version: '1.0', ext: 'aar')
  (...)
}

但是 gradle 找不到 android-library (MyLib1)?我收到以下错误:

 * What went wrong:
 15:50:50.110 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred configuring root project 'workspace'.
 15:50:50.111 [ERROR] [org.gradle.BuildExceptionReporter] > Failed to notify project evaluation listener.
 15:50:50.111 [ERROR] [org.gradle.BuildExceptionReporter]    > Could not resolve all dependencies for configuration ':_DebugCompile'.
 15:50:50.112 [ERROR] [org.gradle.BuildExceptionReporter]       > Could not find MyGroup:MyLib1:1.0.
 15:50:50.113 [ERROR] [org.gradle.BuildExceptionReporter]         Required by:
 15:50:50.113 [ERROR] [org.gradle.BuildExceptionReporter]             MyGroup:workspace:1.0

如何解决我的 android 库?有没有办法“调试”依赖关系?

注意:“MyGroup”是“myvirtualrepository”的一部分

编辑:来自虚拟存储库的跟踪输出

Request ID: 8c181328
Repo Path ID: myvirtualrepository:mygroup/mylib1/1.0/mylib1-1.0.aar
Method Name: GET
User: admin
Time: 2013-11-24T18:05:26.079+01:00
Thread: http-bio-8081-exec-8
Steps: 
2013-11-24T18:05:26.079+01:00 Received request
2013-11-24T18:05:26.079+01:00 Request source = 0:0:0:0:0:0:0:1, Last modified = 01-01-70 00:59:59 CET, If modified since = -1, Thread name = http-bio-8081-exec-8
2013-11-24T18:05:26.079+01:00 Executing any BeforeDownloadRequest user plugins that may exist
2013-11-24T18:05:26.079+01:00 Retrieving info
2013-11-24T18:05:26.079+01:00 Consulting the virtual repo download strategy
2013-11-24T18:05:26.079+01:00 Trying to retrieve resource info from the local storage
2013-11-24T18:05:26.080+01:00 Unable to find resource in myvirtualrepository:mygroup/mylib1/1.0/mylib1-1.0.aar
2013-11-24T18:05:26.080+01:00 Searching for info in aggregated repositories
2013-11-24T18:05:26.080+01:00 Preparing list of aggregated repositories to search in
2013-11-24T18:05:26.081+01:00 Appending the virtual repository 'myvirtualrepository'
2013-11-24T18:05:26.081+01:00 Appending the virtual repository 'myvirtualrepository'
2013-11-24T18:05:26.081+01:00 Appending the virtual repository 'myvirtualrepository'
2013-11-24T18:05:26.081+01:00 Appending collective local repositories
2013-11-24T18:05:26.081+01:00 Appending collective local cache repositories
2013-11-24T18:05:26.081+01:00 Appending collective remote repositories
2013-11-24T18:05:26.081+01:00 Intercepting info request with 'PomInterceptor'
2013-11-24T18:05:26.082+01:00 Intercepting info request with 'MavenMetadataInterceptor'
2013-11-24T18:05:26.082+01:00 Processing request as a release resource
2013-11-24T18:05:26.082+01:00 Searching for the resource within mylocalrepository
2013-11-24T18:05:26.085+01:00 Resource was found in mylocalrepository
2013-11-24T18:05:26.085+01:00 Resource is an exact match - returning
2013-11-24T18:05:26.085+01:00 Returning resource as found in the aggregated repositories
2013-11-24T18:05:26.086+01:00 Intercepting found resource with 'PomInterceptor'
2013-11-24T18:05:26.086+01:00 Intercepting found resource with 'MavenMetadataInterceptor'
2013-11-24T18:05:26.086+01:00 Requested resource is found = true
2013-11-24T18:05:26.086+01:00 Request is HEAD = false
2013-11-24T18:05:26.086+01:00 Request is for a checksum = false
2013-11-24T18:05:26.086+01:00 Target repository is not remote or doesn't store locally = true
2013-11-24T18:05:26.086+01:00 Requested resource was not modified = false
2013-11-24T18:05:26.086+01:00 Responding with found resource
2013-11-24T18:05:26.086+01:00 Executing any AltResponse user plugins that may exist
2013-11-24T18:05:26.086+01:00 Alternative response status is set to -1 and message to 'null'
2013-11-24T18:05:26.086+01:00 Found no alternative content handles
2013-11-24T18:05:26.086+01:00 Retrieving a content handle from target repo
2013-11-24T18:05:26.086+01:00 The requested resource isn't pre-resolved
2013-11-24T18:05:26.086+01:00 Target repository isn't virtual - verifying that downloading is allowed
2013-11-24T18:05:26.086+01:00 Creating a resource handle from 'mylocalrepository:mygroup/mylib1/1.0/mylib1-1.0.aar'
2013-11-24T18:05:26.087+01:00 Identified requested resource as a file
2013-11-24T18:05:26.087+01:00 Requested resource is an ordinary artifact - using normal content handle with length '1614343'
2013-11-24T18:05:26.087+01:00 Executing any BeforeDownload user plugins that may exist
2013-11-24T18:05:26.087+01:00 Responding with selected content handle
2013-11-24T18:05:26.087+01:00 Request succeeded

来自本地存储库的跟踪命令

Request ID: f782a19f
Repo Path ID: mylocalrepository:mygroup/mylib1/1.0/mylib1-1.0.aar
Method Name: GET
User: anonymous
Time: 2013-11-25T14:53:09.336+01:00
Thread: http-bio-8081-exec-2
Steps: 
2013-11-25T14:53:09.336+01:00 Received request
2013-11-25T14:53:09.336+01:00 Request source = 0:0:0:0:0:0:0:1, Last modified = 01-01-70 00:59:59 CET, If modified since = -1, Thread name = http-bio-8081-exec-2
2013-11-25T14:53:09.336+01:00 Executing any BeforeDownloadRequest user plugins that may exist
2013-11-25T14:53:09.336+01:00 Retrieving info
2013-11-25T14:53:09.340+01:00 Requested resource is found = true
2013-11-25T14:53:09.340+01:00 Request is HEAD = false
2013-11-25T14:53:09.340+01:00 Request is for a checksum = false
2013-11-25T14:53:09.341+01:00 Target repository is not remote or doesn't store locally = true
2013-11-25T14:53:09.341+01:00 Requested resource was not modified = false
2013-11-25T14:53:09.341+01:00 Responding with found resource
2013-11-25T14:53:09.341+01:00 Executing any AltResponse user plugins that may exist
2013-11-25T14:53:09.341+01:00 Alternative response status is set to -1 and message to 'null'
2013-11-25T14:53:09.341+01:00 Found no alternative content handles
2013-11-25T14:53:09.341+01:00 Retrieving a content handle from target repo
2013-11-25T14:53:09.341+01:00 The requested resource isn't pre-resolved
2013-11-25T14:53:09.341+01:00 Target repository isn't virtual - verifying that downloading is allowed
2013-11-25T14:53:09.341+01:00 Creating a resource handle from 'mylocalrepository:mygroup/mylib1/1.0/mylib1-1.0.aar'
2013-11-25T14:53:09.342+01:00 Identified requested resource as a file
2013-11-25T14:53:09.342+01:00 Requested resource is an ordinary artifact - using normal content handle with length '1614343'
2013-11-25T14:53:09.343+01:00 Executing any BeforeDownload user plugins that may exist
2013-11-25T14:53:09.343+01:00 Responding with selected content handle
2013-11-25T14:53:09.343+01:00 Request succeeded

谢谢:)

【问题讨论】:

    标签: gradle artifactory


    【解决方案1】:

    有一种调试 Artifactory 分辨率的简单方法 - the trace command

    在你的情况下,你应该运行http://localhost:8081/artifactory/myvirtualrepository/MyGroup/MyLib1/1.0/MyLib1-1.0.jar?trace

    输出很简单,但如果您需要其他帮助,可以将输出添加到问题中,我们会解决的。

    因此,关于您的跟踪 - 它表明工件已找到并成功下载。您可以使用浏览器从虚拟存储库下载工件吗?浏览到http://localhost:8081/artifactory/myvirtualrepository/MyGroup/MyLib1/1.0/MyLib1-1.0.aar

    那么本地 repo (http://localhost:8081/artifactory/mylocalrepository/MyGroup/MyLib1/1.0/MyLib1-1.0.aar) 呢?

    【讨论】:

    • 感谢您的帮助,我将跟踪命令输出添加到我的问题中。
    • 是的,我可以从本地和虚拟仓库下载库。我还添加了本地存储库的跟踪输出。
    • 所以,这是 Gradle 与 Artifactory 的连接。它可以是某种代理吗?另一种方法是使用Artifactory Gradle plugin,也许你会比使用常规的 Maven 解析器更幸运。
    • 没有代理,我在虚拟机上测试artifactory和jenkins,防火墙也关闭了。我用 Artifactory Gradle Plugin 试了一下,得到了同样的错误。使用 --debug 选项,我注意到这一行: 21:26:52.640 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Attempting to resolve module 'MyGroup:MyLib1:1.0' using repositories [ ]。插件找不到存储库列表?
    • 当我在 curl 中使用 ?trace 或通过启动浏览器运行时,它只会将我带到托管工件的工件页面。是否不再支持此跟踪?
    【解决方案2】:

    在我删除了 Jenkins Artifactory Plugin 之后,它终于与 Gradle Artifactory Plugin 一起工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-10
      • 1970-01-01
      • 2017-04-10
      • 1970-01-01
      • 2013-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多