Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have an error that I don't understand and I don't know how to solve it, altough having tried a lot. The error is:

Could not find com.android.tools.build:gradle:7.6.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.6/gradle-7.6.pom
  - https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.6/gradle-7.6.pom
Required by:
    project :
Add google Maven repository and sync project
Open File

So something is wrong with my Java edition or the connection to the build.grandle file. I have Java JDK 19. Here is the code of the build.gradle file

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        def nav_version = "2.3.0"
        classpath 'com.android.tools.build:gradle:7.6'
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
        classpath 'com.google.gms:google-services:4.3.10'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://dl.google.com/android/maven2'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

And here is the gradle.wrapper-properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

According to this website https://docs.gradle.org/current/userguide/compatibility.html, Java 19 is compatible with gradle-7.6. So I dont understand why I still get the error.

Update: I tried what is suggested but still get an error message. Here are my files

build.gradle (DrinkServer):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        def nav_version = "2.3.0"
        classpath ("com.android.tools.build:gradle:7.4.2")
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
        classpath 'com.google.gms:google-services:4.3.10'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven {
            url 'https://dl.google.com/android/maven2'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

build.gradle (app):

plugins {
    id 'com.android.application'
}

apply plugin: "androidx.navigation.safeargs"
apply plugin: 'com.google.gms.google-services'


android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"


    defaultConfig {
        applicationId "com.example.drinkserver"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode 1
        versionName "1.1"
        resConfigs "en", "de"
        viewBinding {
            enabled = true
        }

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

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

dependencies {
    implementation 'androidx.navigation:navigation-runtime:2.3.5'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    def nav_version = "2.3.0"
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    testImplementation 'org.robolectric:robolectric:3.0'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'android.arch.core:core-testing:1.2.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation "androidx.recyclerview:recyclerview:1.1.0"
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation "androidx.navigation:navigation-fragment:$nav_version"
    implementation "androidx.navigation:navigation-ui:$nav_version"
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    implementation 'com.intuit.ssp:ssp-android:1.0.6'
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
    implementation platform('com.google.firebase:firebase-bom:29.0.3')
    implementation 'com.google.firebase:firebase-database'


}

gradle-wrapper. properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

I get the error message "The Android Gradle plugin supports only Kotlin Gradle plugin version 1.5.20 and higher. The following dependencies do not satisfy the required version: root project 'DrinkServer' -> androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0 -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20 "

This is kind of strange as I don't use Kotlin at all (only Java)

Reminder: As I still have this problem (altough having spent quite some time on it) I would like to remind you on this question. Does anyone have a suggestion as to why this is happening and how to solve this issue? I'll appreciate every comment.

like image 588
VanessaF Avatar asked Sep 03 '26 15:09

VanessaF


1 Answers

I could not see any gradle version 7.6 in distribution.
gradle distribution snapshot
Can you change

distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip

dependencies {
        classpath ('com.android.tools.build:gradle:7.4.2')
    }

Please add this in your build.gradle Make sure distribution gradle url is 7.6.1 and in dependancies its like 7.4.2
Graddlewrapper
Build.gradle

like image 132
Jeeva Avatar answered Sep 06 '26 03:09

Jeeva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!