栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

问题描述

把Gradle插件版本更新到7.0.2之后编译失败,出现如下错误:

A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.
解决思路

解决思路来自stackoverflow

用终端进入项目所在位置,找到gradlew并执行如下命令

$ ./gradlew --version

会输出类似这样的信息,我们需要关注的是JVM版本

Welcome to Gradle 7.0.2!

Here are the highlights of this release:
 - File system watching enabled by default
 - Support for running with and building Java 16 projects
 - Native support for Apple Silicon processors
 - Dependency catalog feature preview

For more details see https://docs.gradle.org/7.0.2/release-notes.html


------------------------------------------------------------
Gradle 7.0.2
------------------------------------------------------------

Build time:   2021-05-14 12:02:31 UTC
Revision:     1ef1b260d39daacbf9357f9d8594a8a743e2152e

Kotlin:       1.4.31
Groovy:       3.0.7
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          17 (Oracle Corporation 17+35-LTS-2724)
OS:           Mac OS X 11.6 x86_64

如果JVM指向1.8版本,我们应该把它设置为该Gradle版本需要的版本。
Preferences > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/318296.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号