ChatGPT解决这个技术问题 Extra ChatGPT

Configuration on demand is not supported by the current version of the Android Gradle plugin

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.


W
Willi Mentzel

No need to downgrade!

Disabling configure on demand requires two steps:

Remove org.gradle.configureondemand from gradle.properties. 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

In your project gradle.properties ${HOME}/.gradle/gradle.properties


This has worked, after upgrading android studio and gradle. Setting this org.gradle.configureondemand=false does not work.
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.
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!!!
@BozicNebojsa, your comment deserves to be posted as an answer. Thanks.
@BozicNebojsa right, it's the default behavior. As doc 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.
S
Sidonai

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.


H
Hanhan

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


maybe you should downgrade plugin gradle version or using gradle default from AS
Maybe Google shouldn't release broken tools.
Hi, no need to downgrade anything at all. Please take a look here
T
TapanHP

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

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

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

https://i.stack.imgur.com/KiClR.png


A
Alex Felipe

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

https://i.stack.imgur.com/6cAht.png


I like this option more because it doesn't require other developers to change their IDE settings in order to build your project.
M
Monir Zzaman

From Android Studio uncheck the configure on demand:

Follow below steps:

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.

Now sync your project

Happy coding! :)


B
Bozic Nebojsa

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


C
Chetan Patel

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


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

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


M
Micer

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.


e
eli

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

https://i.stack.imgur.com/LUseR.png


B
Braian Coronel

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