Could not resolve all dependencies for configuration ':app debug Runtime Classpath'

Viewed 24076

I am upgrade my android project gradle 5.4.1-all to 6.5-bin, and upgrade build tools 4.0.0 to 4.1.0, then i am get an error like this

Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
Could not create task ':app:minifyReleaseWithR8'.
Cannot query the value of this provider because it has no value available.
4 Answers

upgrading build tools from 4.0.0 to 4.1.0 doesn't sound right to me--

To set the buildToolsVersion (e.g. to '30.0.5') in your build.gradle file, I suggest going to Tools > SDK Manager, then going to the "SDK Tools" tab; here I find the default view misleading, because it shows a certain version of the "Android SDK Platform-Tools" (the one you might have upgraded to) - but then when you tick the option "Show Package Details", you see another version actually installed. And so I recommend setting the buildToolsVersion to this latter installed version.

Double check the type on what you are assigning to your compileSdkVersion in the build.gradle files.

If you are using a value from gradle.properties you need to parse it into an integer first or you will get this R8 task related crash due to that tasks configuration running triggering further resolution of dependency configurations.

so if you have something like this in your build.gradle:

android {
  compileSdkVersion project.targetSdk
  ...
}

and this in your gradle.properties:

targetSdk=30

you need to parse the integer from the string.

android {
  compileSdkVersion Integer.parseInt(project.targetSdk)
  ...
}

In gradle file, you must have buildtools version, something like:

buildToolsVersion 29.0.3

Make sure you have this version downloaded, the problem is mostly caused by you have no this build tools version. Download it fron Android Studio sdk manager -> SDK tools tab.

a work around for me in build.gradle app level was to downgrade from:

compileSdkVersion 32
buildToolsVersion '32.0.0'

to :

compileSdkVersion 32
buildToolsVersion '30.0.3'

Noting that : current config in build.grade project level is:

    projectMinSdkVersion = 16      
    projectTargetSdkVersion = 30   
Related