Home > OS >  com.android.tools.build:gradle:7.4.1 missing. Gradle doesn't sync
com.android.tools.build:gradle:7.4.1 missing. Gradle doesn't sync

Time:03-18

I'm new to Android studio and I'm trying to set up a new project but I face this error message:

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

I searched the Gradle website and found out 7.0.4 which was set on my Android studio by default, does not exist in the official repository. So I downloaded another version (7.4.1) and changed the version in the build.gradle file but it didn't solve the problem. I downloaded Gradle by using the gradle-wrapper.properties file and it still doesn't work. Then I tried to use the gradle plogin offline by turning on the offline mode and changing the location in file > settings > Build, Execution, Deployment > Build tools > Gradle and it shows me this error message:

A problem occurred configuring root project 'My Application'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:7.4.1.
     Required by:
         project :
      > No cached version of com.android.tools.build:gradle:7.4.1 available for offline mode.
      > No cached version of com.android.tools.build:gradle:7.4.1 available for offline mode.

Possible solution:
 - Disable offline mode and rerun the build

It seems that com.android.tools.build:gradle:7.4.1 is nowhere... I checked the version in Project Structure... and it's 7.4.1 exactly what it is supposed to be. My Android version is 2020.3.1. I'm stuck. How can I fix this? My project doesn't sync and I can't even start...

CodePudding user response:

In the build.gradle Project level set classPath as follow:

buildscript {
   // ...
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.4"

    }
}

in the gradle-wrapper.properties set :

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

Disable gradle offline mode , use VPN and sync your gradle

CodePudding user response:

Option 1

You can try this

  1. Install gradle manually on gradle official website
  2. Extract gradle.zip file (remember the location)
  3. Open android studio > file > settings > Build, execution, deployment > build tools > gradle
  4. In use gradle from select spesified location and go to your gradle location (Example, C:/gradle/gradle7.0.4)

After this, gradle problem should fix, and try to disable gradle offline mode

Option 2

  1. In file > project structure > Project
  2. Set gradle plugin to 7.1.2 and gradle version to 7.4.1
  • Related