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

21

86

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

Mastodon answered 21/10, 2020 at 8:43 Comment(0)
J
144

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)

Joli answered 6/11, 2020 at 15:19 Comment(6)
That was my error too. Android Studio came with sdk 30, but my compileSdkVersion was 29. And the error shown doesn't help you at all.Milomilon
and make sure google play services sdk is installedBronson
Thanks. Solved. The same reason in my case.Trajan
Helped us too, it seems like later API versions have lost support in the upgrade. For us we picked the Android API 28 and 29Fra
hello i have same issue but unable to resolveBufflehead
I have this error with libGDX and worked perfectly. android/build.gradle used sdk 31 but only had sdk 30 installed. You can easily install a new sdk in file/settings/appareance & behaviour/system settings/android SDKProbative
L
13

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

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"
    ...
    ...}
Leet answered 14/4, 2021 at 2:33 Comment(1)
That worked for me! Maybe also downloading SDKs down to Lollipop and the Play SDK, but nothing worked until I added the buildToolsVersion line. Funny, I'm going through this so that I can run a Google CodeLab project, and I almost gave up on learning what I'm trying to learn because it was so hard to figure out how to do nothing more than build the dang project. Thank you!!Anselmi
G
12

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
Gleet answered 23/12, 2020 at 1:46 Comment(3)
'android.enableR8' is deprecated and was removed in Gradle 7.0Ailurophile
@Ailurophile you may be correct. My answer was valid at the time when I posted. Actually Its the nature of the technology world. You should have seen the posted date. ;)Gleet
I do not see this (deprecation) being mentioned in the release docs. R8 is enabled by default since AGP 3.4.0+, so @Yodagama , not sure how this line worked for you if you were using AGP 3.4.0 or higher as it should have been enabled by default.Normative
N
9

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.

Normative answered 2/10, 2021 at 19:43 Comment(0)
A
7

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
Amsterdam answered 27/1, 2021 at 16:46 Comment(0)
A
7

In my case, just delete buildToolsVersion config. like change

compileSdkVersion 31
buildToolsVersion '31.0.0'

to

compileSdkVersion 31
Aforethought answered 23/5, 2022 at 14:35 Comment(0)
Q
3

Commenting this line

//            minifyEnabled true

solved the problem.

Queensland answered 15/8, 2022 at 3:24 Comment(5)
You didn't solve the problem, you disabled minification!Shayneshays
I believe it's not needed in newer versions, is it?Semiconductor
Of course it is, what changed was the engine that performs the minification which now is R8.Shayneshays
I read it somewhere, but not remember exactly. minification is not needed any more in newer version. please double check.Semiconductor
I don't really need to double check. If you read the jetpack compose performance docs, they are encouraging to minify: developer.android.com/jetpack/compose/performanceShayneshays
A
2

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"
    ...
}
Astrid answered 24/5, 2021 at 6:55 Comment(0)
K
1

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.

Kitti answered 22/10, 2020 at 7:52 Comment(0)
G
1

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.

Gazo answered 22/5, 2021 at 19:51 Comment(0)
C
1

Although the error message mention about minification:

Could not create task ':app:minifyReleaseWithR8'.

is not necessary to disable de minification!, it does´t solve the problem

 //minifyEnabled true
 minifyEnabled false

My app was oriented to android 31, but the SDK was not installed!

android {
    compileSdkVersion 31
    ndkVersion "21.3.6528147"
    buildToolsVersion "30.0.3"
    defaultConfig {
        applicationId "com.jorgesys.news"
        minSdkVersion 20
        targetSdkVersion 31
        versionCode 12
        versionName "1.2.9"

to solve this issue you must be sure to have the correct SDK installed.

jorgesys android studio

Cuba answered 20/9, 2022 at 16:4 Comment(0)
M
1

Had the same problem but my solution was to go to sdk-build installation folder and make copies of two files and naming it as "dx". (This appears to happen only for 31.0.0 buildToolsVersion or above)

Go to sdk-build folder under: C:/Users/user/AppData/Local/Android/Sdk/build-tools/{buildToolsVersion}

In this folder you will find d8.bat and make a copy of it and rename newly created copy as "dx.bat".

Next you go to subfolder "lib" and you will find "d8.jar", do the same with this file and it should work.

Melesa answered 24/1, 2023 at 11:48 Comment(0)
G
0

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

Gamin answered 16/11, 2020 at 6:2 Comment(0)
G
0

I solve it to download the right build tools version with sdk manager.for ex. 29.0.2

Guilford answered 30/3, 2021 at 13:22 Comment(0)
N
0

In my case just changing compileSdkVersion number in build.gradle(module) solved the issue.

Nosography answered 8/5, 2021 at 6:21 Comment(0)
M
0
  1. find your buildToolsVersion in app/build.gradle
  2. File>Settings>Appearance&Behavior>System Settings>Android SDK>choice the android version of your buildToolsVersion>OK
Mediocre answered 18/8, 2021 at 5:49 Comment(0)
T
0

If any of the answers does not solve issue, this may help you.

I could not generate a signed bundle after enabling

isMinifyEnabled = true

proguardFiles(getDefaultProguardFile("proguard-android.txt"),"proguard-rules.pro")

Make sure the proguard-rules.pro is named correctly and set to the correct path. That fixed my issue.

Tarr answered 5/12, 2022 at 8:27 Comment(0)
A
0

in my case multidex wasn't deleted when running flutter clean. stopping java from task manager and deleting multidex solved it.

Aras answered 12/12, 2022 at 7:12 Comment(0)
B
0

Solution:

In gradle.properties folder,

android.enableR8=true  <--- Add this line

and Change this,

org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

with this,

org.gradle.jvmargs=-Xmx1536M -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

eg:-

android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
org.gradle.jvmargs=-Xmx1536M -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
android.enableR8=true
....
....

That's it. It's Worked for Me!

Bicentenary answered 27/10, 2023 at 9:12 Comment(0)
S
0

For me I just changed buildToolsVersion from "31.0.0" to "30.0.3" in my build.gradle(app) file :

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"
    ...
}
Sharanshard answered 31/3 at 5:18 Comment(0)
F
-3

disconnect from the internet when generating your bundle

Falkner answered 21/10, 2021 at 7:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.