Reputation: 36
I'm working on an Flutter project, and I recently updated Java, Gradle, and Flutter to the latest versions. After the update, I started getting the following errors when trying to build my project:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:8.9.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.9.0/gradle-8.9.0.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.9.0/gradle-8.9.0.pom
Required by:
project :
> Could not find org.codehaus.groovy:groovy-all:latest_version.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/org/codehaus/groovy/groovy-all/latest_version/groovy-all-latest_version.pom
- https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy-all/latest_version/groovy-all-latest_version.pom
Required by:
project :
Here are the details of my project configuration:
android/build.gradle:
buildscript {
ext.kotlin_version = '1.8.22'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.9.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
android/app/build.gradle:
plugins {
id "com.android.application"
id 'com.google.gms.google-services'
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}
android {
namespace 'com.example.chat'
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId = "com.example.chat"
minSdkVersion 23
targetSdkVersion 33
versionCode = flutterVersionCode.toInteger()
versionName = flutterVersionName
}
buildTypes {
release {
signingConfig = signingConfigs.debug
}
}
configurations.all {
resolutionStrategy {
force 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22'
}
}
}
wrapper/gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Environment details:
I've checked the Maven repositories, but I still get the "Could not resolve" errors for com.android.tools.build:gradle:8.9.0
and org.codehaus.groovy:groovy-all:latest_version
.
What could be causing this issue, and how can I resolve it?
Upvotes: 1
Views: 3306
Reputation: 2780
com.android.tools.build:gradle
) does not have same version, since they are different products, each with it own release cycle.That said,8.9.0
is not valid version of com.android.tools.build:gradle
. Latest version now is 8.5.1
and you should use it. Also, you can check latest release here
latest_release
is not correct for using latest version of some dependency. latest.release
should be used. But in any case, this is not preferred way of resolving versions – it's better to use specific versions. Here is docs on that matterUpvotes: 3