我正在尝试在Azure DevOps管道中使用Gradle任务构建Android应用程序
但失败并显示消息“无法解析com.android.tools.build:gradle:8.0.0”。
这是日志:
2023-08-31T19:55:34.0254000Z * What went wrong:
2023-08-31T19:55:34.0354540Z A problem occurred configuring root project 'Prepara2'.
2023-08-31T19:55:34.0455410Z > Could not resolve all files for configuration ':classpath'.
2023-08-31T19:55:34.0555180Z > Could not resolve com.android.tools.build:gradle:8.0.0.
2023-08-31T19:55:34.0656610Z Required by:
2023-08-31T19:55:34.0758410Z project : > com.android.application:com.android.application.gradle.plugin:8.0.0
2023-08-31T19:55:34.0859370Z > No matching variant of com.android.tools.build:gradle:8.0.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.0' but:
2023-08-31T19:55:34.0959660Z - Variant 'apiElements' capability com.android.tools.build:gradle:8.0.0 declares a library, packaged as a jar, and its dependencies declared externally:
2023-08-31T19:55:34.1060840Z - Incompatible because this component declares a component for use during compile-time, compatible with Java 11 and the consumer needed a component for use during runtime, compatible with Java 8
2023-08-31T19:55:34.1161890Z - Other compatible attribute:
2023-08-31T19:55:34.1285110Z - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
2023-08-31T19:55:34.1387100Z - Variant 'javadocElements' capability com.android.tools.build:gradle:8.0.0 declares a component for use during runtime, and its dependencies declared externally:
2023-08-31T19:55:34.1387850Z - Incompatible because this component declares documentation and the consumer needed a library
2023-08-31T19:55:34.1489260Z - Other compatible attributes:
2023-08-31T19:55:34.1590880Z - Doesn't say anything about its target Java version (required compatibility with Java 8)
2023-08-31T19:55:34.1692450Z - Doesn't say anything about its elements (required them packaged as a jar)
2023-08-31T19:55:34.1780470Z - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
2023-08-31T19:55:34.1860490Z - Variant 'runtimeElements' capability com.android.tools.build:gradle:8.0.0 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
2023-08-31T19:55:34.1962210Z - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
2023-08-31T19:55:34.2060230Z - Other compatible attribute:
2023-08-31T19:55:34.2097130Z - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
2023-08-31T19:55:34.2198720Z - Variant 'sourcesElements' capability com.android.tools.build:gradle:8.0.0 declares a component for use during runtime, and its dependencies declared externally:
2023-08-31T19:55:34.2299060Z - Incompatible because this component declares documentation and the consumer needed a library
2023-08-31T19:55:34.2400480Z - Other compatible attributes:
2023-08-31T19:55:34.2502100Z - Doesn't say anything about its target Java version (required compatibility with Java 8)
2023-08-31T19:55:34.2603660Z - Doesn't say anything about its elements (required them packaged as a jar)
2023-08-31T19:55:34.2705300Z - Doesn't say anything about org.gradle.plugin.api-version (required '8.0')
- 我已将app build.gradle文件compileOptions中的java版本从JavaVersion.VERSION_1_8更改为JavaVersion.VERSION_11
- 我已经改变了插件com.android. applicationversion在build.gradle文件使用8.1.0和8.0.0
- 我已经在Azure DevOps管道中测试了Gradle@2和Gradle@3任务
我很感激你的帮助
1条答案
按热度按时间5anewei61#
确保您的项目和**
gradle plugin
使用的Java版本相同。Java 11。在
build.gradle file
**中设置编译选项,如下所示:并确保在build.gradle文件中正确导入依赖项,如下所示:
我的Gradle Android YAML脚本与
gradle clean cache task
参考我的SO线程答案以运行gradle任务