Could not find com.android.tools.build:gradle:8.12

I am getting the following error when i am trying to run my app

Could not find com.android.tools.build:gradle:8.12.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/8.12/gradle-8.12.pom
  - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/8.12/gradle-8.12.pom
  - https://plugins.gradle.org/m2/com/android/tools/build/gradle/8.12/gradle-8.12.pom
Required by:
    root project :

it was working fine before I changed my laptop. On my new laptop when I try to run the app it is giving me this error I even tried changing the version to 8.4 still gives me the same error about v8.5

But when I use version 8.0.2 it gives me

An exception occurred applying plugin request [id: 'kotlin-android']
> Failed to apply plugin 'kotlin-android'.
   > Could not create an instance of type org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension.
      > Could not generate a decorated class for type KotlinAndroidProjectExtension.
         > org/jetbrains/kotlin/tooling/core/HasMutableExtras

Please help me fix this I don’t know what is wrong

build.gradle

buildscript {
    
    repositories {
      google()  // Google's Maven repository
      mavenCentral()  // Maven Central repository
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
        classpath 'com.google.gms:google-services:4.3.15'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10'
    }
}

plugins {
    // Apply the Google Services plugin dependency
    id 'com.google.gms.google-services' version '4.4.2' apply false
    id "org.jetbrains.kotlin.android" version "1.9.10" apply false
}



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
}

app/build.gradle

plugins {
    id "com.android.application"
    id "kotlin-android"
    // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
    id "dev.flutter.flutter-gradle-plugin"
    id "com.google.gms.google-services"
}

android {
    namespace = "com.example.viwaad_1"
    compileSdk 34
    ndkVersion = flutter.ndkVersion

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId = "com.example.viwaad_1"
        // You can update the following values to match your application needs.
        // For more information, see: https://flutter.dev/to/review-gradle-config.
        minSdk 23
        targetSdk 34
        versionCode = flutter.versionCode
        versionName = flutter.versionName
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig = signingConfigs.debug
        }
    }
}

flutter {
    source = "../.."
}

dependencies {
    // Import the Firebase BoM
    implementation platform('com.google.firebase:firebase-bom:33.7.0')

    // Add Firebase Analytics (example: you can add more based on your needs)
    implementation 'com.google.firebase:firebase-analytics:21.0.0'
    implementation 'com.google.firebase:firebase-core:21.1.0'
    implementation 'com.google.firebase:firebase-auth:21.1.0'
    implementation 'com.google.firebase:firebase-firestore:24.2.0'
}

My grade JDK version is 21.0.2

Please help me with this

You confuse Gradle version with Android Gradle Plugin version.
Google unluckily decided to name their artifact of Android Gradle Plugin gradle, but its version has nothing to do with the Gradle version.
8.12 and 8.4 are Gradle version, not Android Gradle Plugin versions.
Android Gradle Plugin versions are always with three parts and the latest is 8.7.3.

Hey so

distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip

this is where I’m supposed to use the gradle version and

classpath 'com.android.tools.build:gradle:8.0.2'

this is where I’m supposed to use the Android gradle plugin version right?

this is where I’m supposed to use the gradle version

Yes, except that you usually should use -bin not -all.
-allis in practically all cases just a waste of time, bandwidth, and disk space for anyone and everything executing the build.

this is where I’m supposed to use the Android gradle plugin version right?

Yes, except that you should usually not use a buildscript { ... } block anyway, but just a plugins { ... } block, then this confusion also cannot happen as easily.


Besides that, I strongly recommend switching to Kotlin DSL. By now it is the default DSL, you immediately get type-safe build scripts, actually helpful error messages if you mess up the syntax, and amazingly better IDE support if you use a good IDE like IntelliJ IDEA or Android Studio.

Thank you, I will update the necessary

1 Like