Android Studio报错:Could not resolve com.android.tools.build:gradle:8.0.0

一、报错信息

Android Studio 新建项目会报以下错误:

Could not resolve com.android.tools.build:gradle:8.0.0.

完整版报错信息如下:

A problem occurred configuring root project 'My Application'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:8.0.0.
     Required by:
         project : > com.android.application:com.android.application.gradle.plugin:8.0.0
         project : > com.android.library:com.android.library.gradle.plugin:8.0.0
      > 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')

在这里插入图片描述

二、解决方案

原因:此为Android Studio默认的JDK版本与项目配置的Gradle所需的JDK不一致导致冲突所致。要求选择同一版本的JDK,可以选择Android Studio自带的jdk17。

解决方案:点击File -->Project Structure ->SDK Location->JDK location gradle Settings,将Gradle user home和项目的Gradle JDK改为一样的版本目录。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
然后点击Try Again,重新编译即可
在这里插入图片描述

  • 9
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
As an AI language model, I don't have access to the specific details of your project or environment. However, here are some general steps you can take to resolve this error: 1. Check your internet connection: Make sure you have a stable internet connection and try re-syncing your project with Gradle by clicking on the "Sync Now" button in the toolbar. 2. Check your Gradle version: Make sure you have the latest version of Gradle installed. You can check the version of Gradle in your project by opening the Gradle panel (located on the right side of the Android Studio window) and looking for the version number. 3. Update your Gradle settings: If you're using an older version of Gradle, you may need to update your Gradle settings to support the latest version of the Android Gradle plugin. You can do this by updating the "build.gradle" file in your project. 4. Check the repository configuration: Make sure that the repository configuration in your "build.gradle" file is correct and up-to-date. You can check the latest version of the Android Gradle plugin and make sure it's included in your repository configuration. 5. Use a stable version: If you're still having trouble with the alpha version, try using a stable version of the Gradle plugin instead. You can do this by updating your "build.gradle" file and specifying a stable version of the Gradle plugin. If none of these steps work, you may need to seek further assistance from the Android community or consult the official documentation.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值