After upgrading to Android Studio 3.1.2 I am getting the following error:
Configuration on demand is not supported by the current version of the Andro
Just you need to update Android Gradle Plugin update to 3.2.0-alpha16.
Android Gradle Plugin update 3.2.0-alpha16 instead of 3.1.2