Could not create task ':app:minifyReleaseWithR8'. Cannot query the value of this provider because it has no value available

I have been trying to sync my project but I'm getting this error on Android studio. I am using android studio 4.1 and gradle 6.5. the problem happen when I upgrade android studio from 4.0 to 4.1enter image description here


Solution 1:

In my case I've just needed to download the correct sdk. Go to SdkManager (for example tap shift key twice and type "sdk manager") and be sure to download the SDK Platform that corresponds to your buildToolsVersion defined in your project's build.gradle.

(I don't know why Android studio was not detecting that sdk was not installed, it may be a bug)

Solution 2:

open your Android/gradle.properties file and make sure android.enableR8=true is exists .. and it i will be better to sure that the content of the file is:

org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true

Solution 3:

For me I just added buildToolsVersion "30.0.3" in my build.gradle(app) file -

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"
    ...
    ...}

Solution 4:

I faced the same problem today and none of the solutions above seemed to work. This is how I resolved it:

  • Comment out "minifyEnabled false/true" in app level build.gradle file
  • sync (for me AS started to proceed without any issues and downloaded the latest gradle plugin - 7.0.2)
  • Once the sync to the new gradle plugin is done, uncomment "minifyEnabled false/true" and run sync again

Remember that R8 is enabled by default since AGP 3.4.0+

My guess is that this was caused by conflict between new AS and corresponding SDK installation and the old gradle config files.