为什么要添加一个仓库来构建.Gradle让它找不到一个依赖?



我看到jCenter将在遥远的将来退役,并且Gradle警告要求停止使用它。因此,我已经开始了转换,因为我看到简单地用mavenCentral()替换jcenter()会导致缺少依赖项,所以我选择在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

Diff

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中心找到了以下依赖项:

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

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

此依赖项是未解决的:unspecified:,它使构建失败。

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

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

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

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

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

相关内容

  • 没有找到相关文章

最新更新