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问题。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

A problem occurred configuring root project 'MyApplication2'.

> 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')

      昨天用老版本的Android Studio 新建了一个Kotlin项目,. 之类的提示没有,应该是环境问题,就升级了Android Studio到最新的电鳗版本,新建kotlin项目就报上述错误。

      搜索了一圈,原来是gradle插件7.4.2版本比较新,需要Java11,以前配置的是Java8,修改下配置就可以了,以mac电脑为例,操作如下:

1、左上角 File ------- Project Structure, 如图:

Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题

 2、SDK Location -----------  Gradle Settings ,如图:

Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题

 3、Gradle JDK, 选择11的,点击OK , 如图:

Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题

 4、Settings.gradle文件里,配置一些仓库地址,如图:

Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题 代码如下:

pluginManagement {
    repositories {
        maven { url 'https://maven.aliyun.com/repository/releases' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url "https://www.jitpack.io" }
        google()
        mavenCentral()
        gradlePluginPortal()
        jcenter()

    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        maven { url 'https://maven.aliyun.com/repository/releases' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url "https://www.jitpack.io" }
        google()
        mavenCentral()
        jcenter()
    }
}
rootProject.name = "MyApplication2"
include ':app'

 5、点击同步按钮,下载相应的库,如图:

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问题

6、 等待下载完毕,可能需要几分钟到几十分钟,只要下载进度是对的,就OK,如图:

Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题

7、. 已经可以正常提示语法了

Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题

好了,又可以愉快的玩耍了。文章来源地址https://www.toymoban.com/news/detail-428989.html

到了这里,关于Android Studio 解决Could not resolve com.android.tools.build:gradle:7.4.2问题的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Could not resolve com.android.tools.build:gradle:7.4.2.

    Android Studio 新建工程时报错 Could not resolve com.android.tools.build:gradle:7.4.2. 原因: Android Studio默认的JDK版本与项目配置的Gradle所需的JDK不一致导致冲突所致 解决方法:进入Preferences-Build,Execution,Deployment-Build Tools-Gradle中,将Gradle user home和项目的Gradle JDK改为一样的版本目录

    2024年02月11日
    浏览(35)
  • Android新项目出错Could not resolve com.android.tools.build:aapt2***

    本人遇到的解决办法: 1、修改项目根目录下的build.gradle文件里下面的版本号 将以上两个的版本号对应改好。具体两个版本号的对应关系,请参看下面的这个博客地址 Android Gradle插件对应的Gradle所需版本_帅次的博客-CSDN博客_gradle版本号对应的版本  

    2024年02月15日
    浏览(36)
  • ChatGPT问答:Android项目报错Could not resolve com.android.tools.build:gradle:7.4.2.

    这个错误提示表明你在构建你的Android项目时,Gradle无法解析com.android.tools.build:gradle:7.4.2这个版本的Gradle插件。可能是因为这个版本的Gradle插件不存在,或者你的网络连接有问题,导致Gradle无法从远程仓库下载这个插件。 为了解决这个问题,你可以尝试以下几个方法: 检查网

    2024年02月08日
    浏览(60)
  • android gradle 8.0.1构建失败(Could not resolve com.android.tools.build:gradle:8.0.1.)

    背景 :初次创建项目失败。 分析: 很可能是java 8的问题,(ps:一般初构建项目,在更新as之后很容易出现这个问题),通常改为Java 11来处理。 打开Android Studio并导航到FileProject Structure。 SDK location面板中点击Gradle Settings 选择Java11或者内置的高版本Java JDK(embedded java sdk) 再次

    2024年02月16日
    浏览(39)
  • Cordova 12编译报错Could not resolve com.android.tools.build:gradle:7.4.2.

    一、在使用Cordova12 创建项目后编译时候报错 A problem occurred configuring root project \\\'HelloCordova\\\'. Could not resolve all files for configuration \\\':classpath\\\'.     Could not resolve com.android.tools.build:gradle:7.4.2.

    2024年02月10日
    浏览(62)
  • 【坑】导入项目报错Could not find com.android.tools.build:gradle:7.4.0

    报错的图没得了,反正就是Could not find com.android.tools.build:gradle:7.4.0 这个报错解决思路: 1、首先导入项目你不要直接File-----Open,你要FIle------New------Import Project 2、看你gradle配置 setting ----- Build,Exception,Deployment-------Gradle ①home是你下载的gradle路径 ②Gradle 的JDK要和项目JDK一致

    2024年02月02日
    浏览(27)
  • android studio构建项目报错Could not create an instance of type com.android.build.api.variant.impl.Applicat

    Could not create an instance of type com.android.build.api.variant.impl.ApplicationVariantImpl 这个错误通常是由于Gradle插件版本不兼容导致的。你可能正在使用的Gradle插件版本与你的Android Studio版本不兼容。 要解决这个问题,你可以尝试以下解决方法: 在你的项目的build.gradle文件中,将com.andro

    2024年02月01日
    浏览(41)
  • 解决Android Studio 运行时could not start avd

    第一次在这里写文章,很激动哇!(虽然已经大四了) 但是我非常想要和朋友们分享如何解决Android Studio 运行时could not start avd的问题,因为我切实体会到了急于解决问题但却没有办法像只无头苍蝇似的,希望我可以帮助到盆友们! 话不多说,先来上图    当我在create devic

    2024年02月09日
    浏览(30)
  • 解决Android Studio-jdk版本不符问题(No matching variant of com.android.tools.build:gradle:7.4.0 was found.)

    目录 问题截图: 错误代码: 错误原因: 解决方法: 今天在打开项目的时候遇到了一些问题: 问题截图: 错误代码: 如下: No matching variant of com.android.tools.build:gradle:7.4.0 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencie

    2024年02月11日
    浏览(44)
  • git解决ssh: Could not resolve hostname gitlab.xxxx.com

    报错:ssh: Could not resolve hostname gitlab.xxxx.com: Name or service not known fatal: Could not read from remote repository. 解决如下:

    2024年02月09日
    浏览(36)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包