问题描述

Configuration on demand is not supported by the current version of the Android Gradle plugin since you are using Gradle version 4.6 or above. Suggestion: disable configuration on demand by setting org.gradle.configureondemand=false in your gradle.properties file or use a Gradle version less than 4.6.

解释

由于使用你正在使用 Gradle 版本4.6或以上,当前版本的 Android 的 Gradle 插件不支持按需配置。建议:通过在你的 gradle.properties 文件中设置 org.gradle.configureondemand=false 禁用按需配置,或者使用一个低于4.6版本的 Gradle。

解决

Goto File -> Settings -> Build, Excecution, Deployment -> Compiler and uncheck Configure on Demand.

NOTE:I am using Android Gradle com.android.tools.build:gradle:3.1.4 and Gradle 4.10.2 (check in File -> Project Structure -> Project).

根据其指示,在 AndroidStudio 中使用 ctrl + shift + F 全局搜索 org.gradle.configureondemand 关键字,将 true 改为 false;若未解决 ctrl + alt + s 调出 setting,取消 Configure on demand 的勾选,如下图:

image.png

重新编译项目,则报错信息消失。

欢迎各位关注在下的微信公众号“张氏文画”,不光有新鲜的 LeetCode 题解(多种思路,包教包会,开拓思维),还有经典的文章及短视频和大家分享,一起嘿嘿嘿

张氏文画.jpg

——乐于分享,共同进步,欢迎留言讨论
——Treat Warnings As Errors
——Any comments greatly appreciated
——Talking is cheap, show me the code
——CSDN:https://blog.csdn.net/u011489043
——简书:https://www.jianshu.com/u/4968682d58d1
——GitHub:https://github.com/selfconzrr