313

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 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.

I attempted following the suggestion but this did not fix the issue. Any ideas? All help is greatly appreciated, thank you.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Dick Lucas
  • 12,289
  • 14
  • 49
  • 76

12 Answers12

710

No need to downgrade!

Disabling configure on demand requires two steps:

  1. Remove org.gradle.configureondemand from gradle.properties.

  2. In Android Studio,
    For Mac go to the Preferences > Build, Execution, Deployment > Compiler and uncheck the configure on demand.
    For Linux/Windows go to the File > Settings > Build, Execution, Deployment > Compiler and uncheck the configure on demand.

Note, there are 2 gradle.properties files

  1. In your project gradle.properties
  2. ${HOME}/.gradle/gradle.properties
Willi Mentzel
  • 27,862
  • 20
  • 113
  • 121
  • 6
    This has worked, after upgrading android studio and gradle. Setting this org.gradle.configureondemand=false does not work. – Neri Apr 24 '18 at 08:20
  • Can you please tell me your exact problem? And what else you've tried to solve it. –  Apr 24 '18 at 09:11
  • Well, I tried restarting AS, mac, invalidate cache, disabling CoD in AS, disabling it in gradle.properties... It keeps showing the same message "Failed to apply plugin [id 'com.android.application'] 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"... – Bozic Nebojsa Apr 24 '18 at 09:49
  • 4
    Do not get why Google did not disable the option by default with AS 3.1.2 as they where not supporting it, instead of blocking all the devs. – carlo.marinangeli Apr 25 '18 at 10:43
  • 15
    The problem was global gradle.properties. In Local one, I tried to override org.gradle.configureondemand=false but somehow it did not work. After editing global ~/.gradle/gradle.properties it works!!! – Bozic Nebojsa Apr 25 '18 at 12:31
  • i had configured it correctly in the properties files but didn't uncheck it in android studio settings—thanks – jacoballenwood Apr 26 '18 at 18:29
  • As pointed out by Bozic Gradle **ignores** the setting in the _gradle.properties_ file which is located in the root of the project. I noticed that Gradle accepts the setting when I pass it as a **command line property** as in `./gradlew -Dorg.gradle.configureondemand=false tasks`. – JJD Apr 30 '18 at 07:40
  • 1
    @BozicNebojsa, your comment deserves to be posted as an answer. Thanks. – azizbekian May 01 '18 at 12:29
  • Anyone encounter a problem when accepted answer's setting doesn't save when you open a second project in new window (even if you unchecked the configure on demand minute ago in this project)? – adek111 May 25 '18 at 08:01
  • 2
    @BozicNebojsa right, it's the default behavior. As [doc](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties) says: The configuration is applied in following order (if an option is configured in multiple locations **the last one wins**): - gradle.properties in project root directory. - gradle.properties in GRADLE_USER_HOME directory. - system properties, e.g. when is set on the command line. – Vincenzo Petronio Jun 05 '18 at 09:49
  • Hey I can't find ${HOME}/.gradle/gradle.properties. I am using Windows 10 and I have installed Android Studio in another Drive. – Zeeshan Ahmad Khalil Jul 31 '18 at 05:20
  • I've set `org.gradle.configureondemand=false` in 1) `$HOME/.gradle/gradle.properties`, 2) `gradle.properties` in the root folder of my project, and 3) `gradle.properties` in the app folder of my project. Still getting this warning when opening the project, so I still have to turn it off in the Android Studio UI. I was hoping by setting the property, this could eliminate this manual step. Note, I did close Android Studio and restart it. – Carmen Aug 10 '18 at 08:45
  • If you are using Intellij 2018.2.2 (instead of Android Studio), then the option is under "Settings" -> "Build, Execution, Deployment" -> "Gradle-Android Compiler". Or you can search for "Configure on demand" in the settings search box. – Rupert Madden-Abbott Sep 02 '18 at 20:34
  • I could find org.gradle.configureondemand from gradle.properties in local nor global in Step 1. Step 2 did work for me. Many thanks! – Nguyen Tan Dat Sep 05 '18 at 06:56
  • 1
    In Android Studio 3.2, I could no longer find the configure on demand checkbox in the `Build, Execution, Deployment` > `Compiler` section of preferences. – stkent Sep 26 '18 at 18:25
  • The preference is now in `Preferences` > `Build, Execution, Deployment` > `Gradle-Android Compiler` for IntelliJ IDEA 2018.3.4 Please update your answer – fdermishin Feb 20 '19 at 06:40
47

In Android Studio, just go to File -> Settings -> Build, Execution, Deployment -> Compiler and click to uncheck the configure on demand option, then click Ok and Sync Project with gradle files again.

Sidonai
  • 3,088
  • 3
  • 13
  • 12
8

I get same error after update to AS 3.1.2. You can still use Gradle version 4.6 but downgrade Android gradle plugin to 3.1.1

EDIT: just invalidate cache and restart

Hanhan
  • 1,309
  • 12
  • 19
  • maybe you should downgrade plugin gradle version or using gradle default from AS – Hanhan Apr 24 '18 at 06:35
  • 8
    Maybe Google shouldn't release broken tools. – AutonomousApps Apr 24 '18 at 06:37
  • 2
    Hi, no need to downgrade anything at all. Please take a look [here](https://stackoverflow.com/questions/49990933/configuration-on-demand-is-not-supported-by-the-current-version-of-the-android-g/49994951#49994951) –  Apr 24 '18 at 06:45
4

It is already known bug in Android studio even in the Documentation, They have mentioned about this Problem.

The easiest way right now is to disable this feature by going

  1. Open the Preferences window by clicking File > Settings (on Mac, Android Studio > Preferences).
  2. In the left pane, click Build, Execution, Deployment > Compiler.
  3. Un check the Configure on demand checkbox.
  4. Click Apply or OK.

Check this Image for warning they have provided for specific Gradle plugin versions.

enter image description here

TapanHP
  • 5,969
  • 6
  • 37
  • 66
4

Other 'solution' is use the suggestion by Android Studio. Plugin Android Gradle 3.1.3 and Gradle version 4.4.

enter image description here

Alex Felipe
  • 101
  • 2
  • 4
  • 1
    I like this option more because it doesn't require other developers to change their IDE settings in order to build your project. – Sam Aug 08 '18 at 00:17
4

From Android Studio uncheck the configure on demand:

Follow below steps:

  1. For Mac go to the Preferences > Build, Execution, Deployment > Compiler and uncheck the configure on demand.

  2. For Linux/Windows go to the File > Settings > Build, Execution, Deployment > Compiler and uncheck the configure on demand.

Now sync your project

Happy coding! :)

Monir Zzaman
  • 459
  • 4
  • 7
3

The @wookupmaker answer is correct. But, if it still doesn't work, the problem migh be a global gradle.properties.

Even if I tried to override

org.gradle.configureondemand=false

in my local(project specific) gradle.properties, somehow it did not work.

After editing global (~/.gradle/gradle.properties) it worked as expected

Bozic Nebojsa
  • 3,606
  • 1
  • 19
  • 17
3

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

Chetan Patel
  • 180
  • 8
  • This looks interesting, but there are two disadvantages: there are already the beta versions available (in other words, the version would have to be changed _much_ more often) and who wants to use an unreleased dependency? But once it's stable, this is the best. – kb1000 Jun 23 '18 at 13:12
2

Invalidate cache and restart/disabling configure on demand did not work for me. The only solution that helped me is to import the project from git again.

[UPD] Need to change "com.android.tools.build:gradle" from 3.1.2 to 3.1.1

whitipet
  • 111
  • 1
  • 6
1

All I needed to do in this case was to use "nuclear function" in Android Studio:

File -> Invalidate Caches / Restart....

Like in many other cases, this helped to make Gradle sync and project build working again. I'm using gradle-4.6-all and Gradle Plugin com.android.tools.build:gradle:3.1.3.

Micer
  • 8,731
  • 3
  • 79
  • 73
0

Go to File->Build,Excution,Deployment->Compiler and Uncheck Configure on Demand

enter image description here

eli
  • 8,571
  • 4
  • 30
  • 40
0

gradle/wrapper/gradle-wrapper.properties

Update the gradle version

distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

Build > Rebuild Project

Good Luck

Source

Braian Coronel
  • 22,105
  • 4
  • 57
  • 62