Could not create task ':app:minifyReleaseWithR8'. Cannot query the value of this provider because it has no value available
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)
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