gpt4 book ai didi

android - 为什么将存储库添加到 build.gradle 会使其找不到依赖项?

转载 作者:行者123 更新时间:2023-12-04 23:54:52 37 4
gpt4 key购买 nike

我看到 jCenter 将在遥远的将来退役,并且 Gradle 警告要求人们停止使用它。因此我已经开始转换,因为我看到简单地将 jcenter() 替换为 mavenCentral() 导致缺少依赖项,我选择在 JCenter 之前添加 Maven Central 作为第一个开始。

据我所知,Gradle 将按顺序访问 Maven 存储库:google,然后是 maven central,然后是 jcenter。但是发生的事情是,当我添加它时,Gradle 无法找到依赖项:

$ time ./gradlew build --stacktrace
FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileReleaseKotlin'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find :unspecified:.
Required by:
project :app > project :cameramodule > id.zelory:compressor:2.1.0

...
Caused by: org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
...
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find :unspecified:.
Required by:
project :app > project :cameramodule > id.zelory:compressor:2.1.0


* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.7.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 15s

差异

Date:   Thu Sep 9 01:46:58 2021 +0200

Prever Maven Central over JCenter repos

diff --git a/build.gradle b/build.gradle
index 6dd00f0..533e262 100644
--- a/build.gradle
+++ b/build.gradle
@@ -4,8 +4,8 @@ buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
- jcenter()
-
+ mavenCentral()
+ jcenter() // read-only as of March 2021
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
@@ -25,8 +25,8 @@ buildscript {
allprojects {
repositories {
google()
- jcenter()
-
+ mavenCentral()
+ jcenter() // read-only as of March 2021
}
}

最佳答案

检查了 id.zelory:compressor:2.1.0 的 .pom 文件来自 maven central 并发现以下依赖项:

<dependency>
<groupId/>
<artifactId>unspecified</artifactId>
<version/>
</dependency>

.pom 链接: https://repo1.maven.org/maven2/id/zelory/compressor/2.1.0/compressor-2.1.0.pom

此依赖项是 Unresolved :unspecified: 使您的构建失败。

显然,这种依赖关系没有任何意义,可能是发布脚本生成了错误的 pom。

你应该实现压缩库并排除奇怪的 :unspecified: 依赖:

implementation('id.zelory:compressor:2.1.0') {
exclude module: 'unspecified'
}

编辑:压缩器的 GitHub 项目有一个问题表明迁移到 maven central 更改了 .pom 文件: https://github.com/zetbaitsu/Compressor/issues/176

编辑 2:显然它已在 2.1.1 版中修复: https://github.com/zetbaitsu/Compressor/issues/179

关于android - 为什么将存储库添加到 build.gradle 会使其找不到依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69134182/

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