Jes*_*rix 6 android gradle android-studio android-safe-args
我在使用 gradlew 和 Java 17 构建 Android 项目时遇到问题。我收到的错误消息是:
“无法解析 androidx.navigation:navigation-safe-args-gradle-plugin - '在编译时使用的组件,与 Java 17 兼容,而消费者需要在运行时使用的组件,与 Java 13 兼容'”
但是,当我通过 Android Studio 构建并运行应用程序时,一切正常。作为 CI 流程的一部分,此错误也会出现在我的 Git Actions 工作流程中。
我的项目需要 Java 版本 17。谁能帮助我理解为什么使用 gradlew 时会出现此错误以及如何解决它?
此外,我很好奇 Android Studio 正在运行的确切命令,因为该项目使用 GUI 成功构建了。了解该命令可能有助于深入了解该问题。
完整信息:
MacBook-Pro:My-Android me$ ./gradlew
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'My-Android'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0.
Required by:
project :
> No matching variant of androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 was found. The consumer was configured to find a library for use during runtime, compatible with Java 13, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '8.1' but:
- Variant 'apiElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component for use during compile-time, compatible with Java 17 and the consumer needed a component for use during runtime, compatible with Java 13
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.1')
- Variant 'runtimeElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 declares a library for use during runtime, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 13
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '8.1')
- Variant 'sourcesElements' capability androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0 declares a component for use during runtime, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 13)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '8.1')
Run Code Online (Sandbox Code Playgroud)
小智 0
我不确定它是否适合您,或者您是否找到了另一个解决方案,但对我来说,它正在更新我的代码中的 CircleCI 图像image: cimg/android:2024.01
。文档在这里找到https://circleci.com/developer/images/image/cimg/android
归档时间: |
|
查看次数: |
632 次 |
最近记录: |