gpt4 book ai didi

android - 无法使用 Gradle 6.1.1 解析 junit-jupiter-params :5. 6.2 和 junit-jupiter-engine :5. 6.2

转载 作者:行者123 更新时间:2023-12-03 03:10:30 28 4
gpt4 key购买 nike

我有一个带有 2 个 Android 模块和一个纯 Java 模块的 Android 项目。
将 android 构建工具更新为 com.android.tools.build:gradle:4.0.0 并将 gradle 包装器更新为 gradle-6.1.1-所有纯 Java 模块都无法解析 junit 了。
与 gradle 文件同步时出现以下错误:

Failed to resolve: org.junit.jupiter:junit-jupiter-params:5.6.2 
Failed to resolve: org.junit.jupiter:junit-jupiter-engine:5.6.2

如果我尝试直接运行测试,我会得到以下输出:
Could not resolve all files for configuration ':domain:testCompileClasspath'.
> Could not resolve org.junit.jupiter:junit-jupiter-params:5.6.2.
Required by:
project :domain
> Cannot choose between the following variants of org.junit.jupiter:junit-jupiter-params:5.6.2:
- javadocElements
- sourcesElements
All of them match the consumer attributes:
- Variant 'javadocElements' capability org.junit.jupiter:junit-jupiter-params:5.6.2:
- Unmatched attributes:
- Found org.gradle.category 'documentation' but wasn't required.
- Found org.gradle.docstype 'javadoc' but wasn't required.
- Required org.gradle.jvm.version '7' but no value provided.
- Required org.gradle.libraryelements 'classes' but no value provided.
- Found org.gradle.status 'release' but wasn't required.
- Required org.jetbrains.kotlin.platform.type 'jvm' but no value provided.
- Compatible attributes:
- Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-runtime'.
- Variant 'sourcesElements' capability org.junit.jupiter:junit-jupiter-params:5.6.2:
- Unmatched attributes:
- Found org.gradle.category 'documentation' but wasn't required.
- Found org.gradle.docstype 'sources' but wasn't required.
- Required org.gradle.jvm.version '7' but no value provided.
- Required org.gradle.libraryelements 'classes' but no value provided.
- Found org.gradle.status 'release' but wasn't required.
- Required org.jetbrains.kotlin.platform.type 'jvm' but no value provided.
- Compatible attributes:
- Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
- Required org.gradle.usage 'java-api' and found compatible value 'java-runtime'.

我如何告诉 Gradle 它应该在哪里寻找正确的 junit 依赖项?

最佳答案

我为类似问题找到的解决方案(我的问题是 org.junit.jupiter:junit-jupiter-api)是将测试的源兼容性更新到 1.8。

compileJava {
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
}
compileTestJava {
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
}

这样,生产源代码仍然与 1.7 兼容,以允许 Android 构建。

关于android - 无法使用 Gradle 6.1.1 解析 junit-jupiter-params :5. 6.2 和 junit-jupiter-engine :5. 6.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62472074/

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