Could not create task ':app:minifyReleaseWithR8'. Cannot query the value of this provider because it has no value available
AndroidGradleAndroid Problem Overview
Android Solutions
Solution 1 - Android
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 - Android
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 - Android
For me I just added buildToolsVersion "30.0.3"
in my build.gradle(app)
file -
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
...
...}
Solution 4 - Android
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.
Solution 5 - Android
The only solution i've got is to enable this line of code from gradle.properties
and make sure this line is not commented:
android.enableR8=true
Do Sync Now (from top right), then it will do the magic..
Wait until sync being finished, and then comment that line again just to silent the deprecated notification:
#android.enableR8=true
Solution 6 - Android
In my case I just update my buildToolsVersion from "29.0.3" to buildToolsVersion "30.0.3" in build.gradle (:app)
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
...
}
Solution 7 - Android
In my case this was because one of the two following things in build.gradle (:app)
, or because of both of them:
- I was still using the old Crashlytics SDK from fabric.io instead of Firebase.
- I had an entry to
apply plugin: 'com.getkeepsafe.dexcount'
Updating Crashlytics didn't help, but removing the dexcount
line fixed the issue.
I hadn't compiled that project in a couple of months, so a lot needed to be upgraded.
Solution 8 - Android
In my case my app/build.gradle
had a buildToolsVersion
that I didn't have installed.
buildToolsVersion '31.0.0-rc3'
But I only had 31.0.0-rc4
installed, having removed 31.0.0-rc3 recently and updated another project, just not this one.
Yes, I would have expected Android Studio (my case 2021.1.1 Canary 1) to say what the problem is explicitly - we should report this.
Solution 9 - Android
- find your buildToolsVersion in app/build.gradle
- File>Settings>Appearance&Behavior>System Settings>Android SDK>choice the android version of your buildToolsVersion>OK
Solution 10 - Android
It's work for me, upgraded dexcount version from
"com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.4"
to
"2.0.0"
then BUILD OK
env:
gradle:6.5
Android Studio:4.1.1
Solution 11 - Android
I solve it to download the right build tools version with sdk manager.for ex. 29.0.2
Solution 12 - Android
In my case just changing compileSdkVersion
number in build.gradle(module) solved the issue.
Solution 13 - Android
In my case, just delete buildToolsVersion config. like change
compileSdkVersion 31
buildToolsVersion '31.0.0'
to
compileSdkVersion 31
Solution 14 - Android
disconnect from the internet when generating your bundle