gpt4 book ai didi

firebase - 为什么Gradle甚至对于离线构建也需要正确配置的 `repositories`关闭?

转载 作者:行者123 更新时间:2023-12-03 05:51:33 26 4
gpt4 key购买 nike

添加新依赖项(Firebase)后,我尝试调试 Gradle缓慢安装问题。

我在allprojects.repositories闭包中有几个条目,像这样:

allprojects {
repositories {
jcenter {
url 'https://internal.example.com/mvn-public/'
}
maven {
url 'https://maven.google.com'
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
maven {
url "https://jitpack.io"
}
}
}

我以为我会删除所有它们,除了Firebase所需的那些,然后检查是否可以加快安装速度,但这由于以下问题而无法正常工作:

当我在添加新的依赖项之前返回 master并进行脱机构建时,它可以正常工作(因为我已经在磁盘上存储了所有内容)-很好:
gradlew build --offline

但是现在,我从 allprojects.repositories闭包中删除所有条目,然后再次运行相同的命令:
gradlew build --offline

令人惊讶的是,我收到一条错误消息,告诉我它无法解决依赖关系。令我惊讶的是,因为我是在一分钟前刚刚用 --offline标志构建的,所以它应该在磁盘上,并且我没有任何通配符依赖项,需要网络查找更新-所有版本都是硬编码的(即 1.4.1,而不是 1.4.*)。
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
> Could not find com.squareup.leakcanary:leakcanary-android:1.5.4.
Required by:
project :app
> Could not find com.google.dagger:dagger:2.12.
Required by:
project :app
> Could not find io.requery:requery:1.4.1.
Required by:
project :app
> Could not find io.requery:requery-android:1.4.1.
Required by:
project :app
...

为什么Gradle在第二种情况下找不到依赖项?

最佳答案

Gradle docs看来,这是故意的

The Gradle cache does not allow the local cache to hide problems and create other mysterious and difficult to debug behavior that has been a challenge with many build tools. This new behavior is implemented in a bandwidth and storage efficient way. In doing so, Gradle enables reliable and reproducible enterprise builds.



...

Dependency resolution will fail if the required artifacts are not available in any repository specified by the build, even if the local cache has a copy of this artifact which was retrieved from a different repository.



但是,为什么在 --offline模式下也会发生这种情况有些令人困惑。

关于firebase - 为什么Gradle甚至对于离线构建也需要正确配置的 `repositories`关闭?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47476228/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com