android studio jdk问题

news/2024/5/3 5:08:48

报错

使用 Terminal 运行命令,报错:

 FAILURE: Build failed with an exception.* What went wrong:
A problem occurred configuring root project 'StringFog'.
> Could not resolve all files for configuration ':classpath'.> Could not resolve com.android.tools.build:gradle:8.0.0.Required by:project :> 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:- Variant 'apiElements' capability com.android.tools.build:gradle:8.0.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 11 and the consumer needed a component for use during runtime, compatible with Java 8- Other compatible attribute:- Doesn't say anything about org.gradle.plugin.api-version (required '8.0')- Variant 'javadocElements' capability com.android.tools.build:gradle:8.0.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 8)- 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.0')- 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:- Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8- Other compatible attribute:- Doesn't say anything about org.gradle.plugin.api-version (required '8.0')- Variant 'sourcesElements' capability com.android.tools.build:gradle:8.0.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 8)- 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.0')> Could not resolve --------------------略* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 857ms

重点为 Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8

应该是 jdk 版本不对。

但是查资料,在 ide 修改 Gradle 的 jdk 为 11、17 都无效。

解决历程

  1. 在 Terminal 使用命令 java -version 可以显示 jdk 11。但是转念一想我系统变量 JAVA_HOME 配的 1.8,蛮奇怪的,会不会有什么冲突。
  2. 修改系统变量 JAVA_HOME 为 jdk 11 版本,以及 Path 变量里的 bin 路径。
  3. 测试正常
  4. 应用打包会提示 Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
  5. 这次使用 IDE 的设置,打开设置搜索 Terminal,在 Project Setting 里设置终端的环境变量:Environment variables: JAVA_HOME=E:/Program Files/Android/Android Studio/jbr,这个是 ide 自带的 17 jdk。
  6. 命令执行正常。

done.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hjln.cn/news/22322.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈,一经查实,立即删除!

相关文章

使用Lagent AgentLego 搭建智能体

对于这个作业,这里只给出截图,不给详细过程,因为确实没有什么好写的。具体的步骤可以查看官方教程。 作业要求 基础作业完成 Lagent Web Demo 使用,并在作业中上传截图。文档可见 Lagent Web Demo 完成 AgentLego 直接使用部分,并在作业中上传截图。文档可见 直接使用 Age…

RILIR 复现 一些 idea

伪代码:在 if done 的时候,在环境中已经跑了一个 trajectory 了,利用当前的 trajectory 和专家的 demo 求一下 reward(文章中用的是 optimal transport 的几种方法) 否则,就继续在 observation 的基础上利用 actor 学到的策略 sample 出 action,并用 list 记录下当前的 …

LCD显示器 --- 8080接口 和 RGB接口 的区别

主要介绍LCD显示的基本原理,涉及像素、分辨率、颜色模型、RGB888等格式、Framebuffer、8080接口、RGB接口。 1.LCD显示出图片的基本原理 LCD作为显示器,它的显示原理和图片是一样的。 图片可以看作由一个一个点(即像素pixel)组成。每行有xres个像素,有yres行,则这个图片的分…

Ubuntu 22.04 解决和 Windows 共享蓝牙设备的问题

我有一个 Airpods,连接到 WIndows 可以正常工作,但连接到 ubuntu 后会无法连接,只能删除设备选择重联,但是这又会导致 Windows 不能连接到耳机,只能也删除重新连接,费神费力。 要解决此问题,仍有两办法,让 Windows 将就 Linux,或者 Linux 将就 Windows,由于折腾注册表…

【STM32+HAL库】---- 驱动MAX30102心率血氧传感器

硬件开发板:STM32F407VET6 软件平台:cubemax+keil+VScode1 MAX30102心率血氧传感器工作原理 MAX30102传感器是一种集成了红外光源、光电检测器和信号处理电路的高度集成传感器,主要用于心率和血氧饱和度的测量。以下是MAX30102传感器的主要特点和工作原理:红外光源:MAX301…

OO第一次博客作业

OO第一次博客作业 目录1.前言 2.设计与分析 3.采坑心得 4.改进建议 5.总结 1.前言 正则表达式是java语言中一种非常重要的语言,他的重要性主要体现在以下方面: 1.高效的文本处理:正则表达式提供了一种高效的方式来处理文本数据。它可以快速地进行字符串的搜索、匹配、替换和…

JVM——面试

https://juejin.cn/post/6998527815964426271 https://juejin.cn/post/7101120209540349959垃圾回收器 Serial(新生代)+ Serial Old(老年代) 特点:单线程垃圾回收器,垃圾回收过程中需要 STW,适用于运行在 Client 模式下的虚拟机; 新生代标记复制算法,老年代标记整理算法…

2024.4.19

2024.4.19 【你知道的都是真相。只可惜那些并不是真相的全部。】 Friday 三月十一 谷雨<BGM = "谷雨--音阙诗听"> AC :Answer Coarse,粗劣的答案 ​ CE :Compile Easily,轻松通过 ​ PC :Perfect Compile 完美的编译 ​ WA :Wonderful Answer,好答案 ​ RE :Ru…