前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >【错误记录】Android Studio 编译报错 ( Could not resolve com.android.tools.build:gradle:7.4.2. )

【错误记录】Android Studio 编译报错 ( Could not resolve com.android.tools.build:gradle:7.4.2. )

作者头像
韩曙亮
发布于 2023-04-09 02:00:29
发布于 2023-04-09 02:00:29
5.2K00
代码可运行
举报
运行总次数:0
代码可运行

文章目录

一、报错信息


在 Mac 中安装了 Android Studio , 首次创建应用运行时 , 报如下错误 :

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
A problem occurred configuring root project 'DataBinding'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:7.4.2.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:7.4.2
         project : > com.android.library:com.android.library.gradle.plugin:7.4.2
      > No matching variant of com.android.tools.build:gradle:7.4.2 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:7.4.2 declares a library, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
              - Other compatible attribute:
                  - Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
          - Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, 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 '7.5')
          - Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a library, 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 '7.5')
          - Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.2 declares a runtime of a component, 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 '7.5')

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

二、解决方案


报错信息中有提示 : Doesn’t say anything about its target Java version (required compatibility with Java 8)

A problem occurred configuring root project ‘DataBinding’. Could not resolve all files for configuration ‘:classpath’. Could not resolve com.android.tools.build:gradle:7.4.2. Required by: project : > com.android.application:com.android.application.gradle.plugin:7.4.2 project : > com.android.library:com.android.library.gradle.plugin:7.4.2

说明该错误与 JDK 版本相关 , 当前使用的是最新版的 Android Studio , 这里将 JDK 更新成 JDK11 ;

查看当前的 JDK 版本 , 选择 " 菜单栏 / Android Studio / Preferences … " 选项 ,

在 Gradle 配置中 , 可以查看 JDK 版本 , 发现此处配置的 JDK 版本是 JDK8 ;

在 Gradle JDK 选项中 , 选择 JDK 11 选项 ;

设置完毕后 , 重新编译应用 , 编译通过 ;

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-04-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
解决 :A problem occurred configuring root project ‘demo1‘. > Could not resolve all files for configu
博主 默语带您 Go to New World. ✍ 个人主页—— 默语 的博客👦🏻 《java 面试题大全》 🍩惟余辈才疏学浅,临摹之作或有不妥之处,还请读者海涵指正。☕🍭 《MYSQL从入门到精通》数据库是开发者必会基础之一~ 🪁 吾期望此文有资助于尔,即使粗浅难及深广,亦备添少许微薄之助。苟未尽善尽美,敬请批评指正,以资改进。!💻⌨
默 语
2024/11/20
2230
解决 :A problem occurred configuring root project ‘demo1‘. > Could not resolve all files for configu
解决 Spring Boot 和 Gradle Java 版本兼容性问题:A problem occurred configuring root project ‘demo1‘. > Could n
本文将讨论如何解决 Spring Boot Gradle 插件和 Java 版本之间的兼容性问题。特别是当 Spring Boot Gradle 插件要求的 Java 版本与项目当前使用的 Java 版本不匹配时,如何解决这个问题。
猫头虎
2024/04/09
1.5K0
解决 Spring Boot 和 Gradle Java 版本兼容性问题:A problem occurred configuring root project ‘demo1‘. > Could n
Android Gradle 学习笔记整理
对于Android开发人员已经了解build.gradle 的 android{} 和 dependencies{} ,但是他的编译过程是什么样的?这个过程中可以干些什么事了解吗?
做个快乐的码农
2021/12/14
1K0
Android Gradle 学习笔记整理
cas 6.2 Incompatible because this component declares an API of a component compatible with Java 11
https://blog.csdn.net/qq_40297844/article/details/106437993
全栈程序员站长
2021/04/07
1.9K0
【错误记录】Android Studio 编译报错 ( Could not find com.android.tools.build:gradle:4.2.1. )
检查了下根目录下的 build.gradle 配置 , 发现只配置了 jcenter 仓库 ;
韩曙亮
2023/03/29
1.7K0
【错误记录】Android Studio 编译报错 ( Could not find com.android.tools.build:gradle:4.2.1. )
记一次Gradle依赖相关问题
‍最近对之前项目里面依赖的Flutter模块进行了一次升级。因为从1.x升级的时候3.0的flutter需要安卓原生适配compilesdkversion,所以我们APP使用的Flutter版本为2.8.1,现在app的构建版本升上来了,于是对之前的Flutter进行了升级。
烧麦程
2022/12/05
1.3K0
Android Studio 遇到问题集锦
Android Studio First Run 检测 Android SDK 及更新,由于众所周知的原因,我们会「Unable to access Android SDK add-on list」,而且大家一般也已经提前配置好了 Android SDK,真正需要更新的时候手动去 SDK Manager 更新就好了。
mzlogin
2020/04/16
6.9K0
Android Studio 遇到问题集锦
Gradle Plugin for Android Development User Guide 2
Gradle Plugin for Android Development User Guide (2)
宅男潇涧
2018/08/01
6710
Gradle Plugin for Android Development User Guide 2
【错误记录】Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )
文章目录 一、报错信息 二、解决方案 一、报错信息 ---- 编译 VirtualAppEx 源码时 , 报如下错误 : Gradle 'VirtualAppEx-master' project refresh failed Error:Connection timed out: connect 使用 gradlew assembleDebug --stacktrace 命令 , 查看详细报错信息 : D:\002_Project\002_Android_Learn\VirtualApp\003_Vir
韩曙亮
2023/03/29
6330
【错误记录】Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )
Gradle Plugin for Android Development User Guide 1
Gradle Plugin for Android Development User Guide (1)
宅男潇涧
2018/08/01
8720
Gradle Plugin for Android Development User Guide 1
【错误记录】Android Studio 编译报错 ( Deprecated Gradle features were used in this build, making it incompat )
使用 Android Studio 编译比较老的 Android 项目时 , 报如下错误 :
韩曙亮
2023/03/30
2.2K0
【错误记录】Android Studio 编译报错 ( Deprecated Gradle features were used in this build, making it incompat )
【错误记录】Android Studio 编译报错 ( Installed Build Tools revision 31.0.0 is corrupted )
创建 Project 工程时 , 自动创建的 Module 其 build.gradle 为 如下属性 ,
韩曙亮
2023/03/30
1.1K0
【错误记录】Android Studio 编译报错 ( Installed Build Tools revision 31.0.0 is corrupted )
【错误记录】Android Studio 配置 AspectJ 报错 ( Failed to create Jar file C:\xxx\aspectjtools-1.8.10.jar. )
在 Android Studio 中配置 AspectJ , 配置后的 Module 下的 build.gradle 如下 : 这是在 AS 中配置 AspectJ 的固定配置 ;
韩曙亮
2023/03/29
1.5K0
【错误记录】Android Studio 配置 AspectJ 报错 ( Failed to create Jar file C:\xxx\aspectjtools-1.8.10.jar. )
【错误记录】Android Studio 编译报错 ( Invalid main APK outputs : EarlySyncBuildOutput )
选择 " Build | Clean Project " 选项 , 清空编译数据 , 然后重新编译即可 ;
韩曙亮
2023/03/29
1.3K0
【错误记录】Android Studio 编译报错 ( Invalid main APK outputs : EarlySyncBuildOutput )
【错误记录】Android 编译报错 ( The project uses Gradle version which is incompatible with Android Studio )
使用的 ijkplayer 版本是 0.8.8 版本的 , 这是 2018 年的版本 , 生成的 Android Studio 工程源码 也是 在 2018 年运行的 , 当时使用 的
韩曙亮
2023/10/15
1.3K0
【错误记录】Android 编译报错 ( The project uses Gradle version which is incompatible with Android Studio )
Android Gradle 2.3.3 升级 3.0.1 小记录
和尚因为种种原因需要升级 Android Gradle,Gradle > 3.0 时默认支持 Java 8;每次大版本升级都会涉及很多内容,和尚尽可能慎重,但还是简单记录一下升级过程中遇到的问题;
阿策小和尚
2019/12/30
6520
Android Gradle 2.3.3 升级 3.0.1 小记录
【错误记录】Android Studio 编译报错 ( Module was compiled with an incompatible version of Kotlin. ) 2
在之前遇到过类似问题 【错误记录】Android Studio 编译报错 ( Module was compiled with an incompatible version of Kotlin. The binary ) , 报错的依赖库不同 , 本篇博客再次分析一遍 ;
韩曙亮
2023/03/30
4.4K0
【错误记录】Android Studio 编译报错 ( Module was compiled with an incompatible version of Kotlin. ) 2
【错误记录】AS 编译报错 ( Android Support plugin 版本太高 | 升级 Android Studio 到最新版本 )
当前的 Android 支持插件无法打开该工程 , 将 Android Studio 升级到
韩曙亮
2023/03/29
1.8K0
【错误记录】AS 编译报错 ( Android Support plugin 版本太高 | 升级 Android Studio 到最新版本 )
Android Studio的build.gradle文件使用(一)
Gradle 是一个非常先进强大的项目构建工具,它使用了一种基于 Groovy 领域的特定语言(DSL)来声明项目设置。
李小白是一只喵
2020/11/26
8610
Android Studio的build.gradle文件使用(一)
【错误记录】Android Studio 编译报错 ( Could not determine java version from ‘11.0.8‘. ② | 升级 Gradle 版本 )
解决 Could not determine java version from '11.0.8'. 问题 , 有两种方案 ,
韩曙亮
2023/03/30
1.2K0
【错误记录】Android Studio 编译报错 ( Could not determine java version from ‘11.0.8‘. ② | 升级 Gradle 版本 )
推荐阅读
解决 :A problem occurred configuring root project ‘demo1‘. > Could not resolve all files for configu
2230
解决 Spring Boot 和 Gradle Java 版本兼容性问题:A problem occurred configuring root project ‘demo1‘. > Could n
1.5K0
Android Gradle 学习笔记整理
1K0
cas 6.2 Incompatible because this component declares an API of a component compatible with Java 11
1.9K0
【错误记录】Android Studio 编译报错 ( Could not find com.android.tools.build:gradle:4.2.1. )
1.7K0
记一次Gradle依赖相关问题
1.3K0
Android Studio 遇到问题集锦
6.9K0
Gradle Plugin for Android Development User Guide 2
6710
【错误记录】Android Studio 编译报错 ( Error:Connection timed out: connect | 更新配置依赖仓库方式 )
6330
Gradle Plugin for Android Development User Guide 1
8720
【错误记录】Android Studio 编译报错 ( Deprecated Gradle features were used in this build, making it incompat )
2.2K0
【错误记录】Android Studio 编译报错 ( Installed Build Tools revision 31.0.0 is corrupted )
1.1K0
【错误记录】Android Studio 配置 AspectJ 报错 ( Failed to create Jar file C:\xxx\aspectjtools-1.8.10.jar. )
1.5K0
【错误记录】Android Studio 编译报错 ( Invalid main APK outputs : EarlySyncBuildOutput )
1.3K0
【错误记录】Android 编译报错 ( The project uses Gradle version which is incompatible with Android Studio )
1.3K0
Android Gradle 2.3.3 升级 3.0.1 小记录
6520
【错误记录】Android Studio 编译报错 ( Module was compiled with an incompatible version of Kotlin. ) 2
4.4K0
【错误记录】AS 编译报错 ( Android Support plugin 版本太高 | 升级 Android Studio 到最新版本 )
1.8K0
Android Studio的build.gradle文件使用(一)
8610
【错误记录】Android Studio 编译报错 ( Could not determine java version from ‘11.0.8‘. ② | 升级 Gradle 版本 )
1.2K0
相关推荐
解决 :A problem occurred configuring root project ‘demo1‘. > Could not resolve all files for configu
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
本文部分代码块支持一键运行,欢迎体验
本文部分代码块支持一键运行,欢迎体验