Recently I updated a 1 year old android project (gradle, SDK, libraries, etc.) and bump into the following exception
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.
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).
References: