skip to Main Content

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 plugin 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…

6

Answers


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

    buildscript {
       repositories {
        google()
        mavenCentral()
    }
        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

    Login or Signup to reply.
  2. 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
    Login or Signup to reply.
  3. Do the following:

    Step one:

    1.1. Open file > project structure > Project
    1.2. Set gradle plugin to 7.1.2 and gradle version to 7.4.1

    Step two

    2.1. Find and open In the build.gradle (Project: ) level.
    2.2. Find the first repository inside buildscript and replace it with the following;

    repositories{ google() mavenCentral() }

    2.3. Also find the second repository inside allprojects and replace it with the following;

    repositories{ google() mavenCentral() }

    2.4. Then find classpath inside dependencies and replace it with the following:

    dependencies{ classpath “com.android.tools.build:gradle:7.0.4” }

    Step Three

    3.0. Make sure you are connected to the internet, then click the Sync button.

    Login or Signup to reply.
  4. I had a Flutter Project with this problem – the solution was:

    1. From your project root go to /android/gradle/wrapper/gradle-wrapper.properties
    2. Updated distributionUrl -> distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip

    That was it.

    Login or Signup to reply.
  5. For me worked changing the Gradle JDK to Embedded JDK (JetBrains Runtime version 11.01.12) in:

    file > settings > Build, execution, deployment > build tools > gradle

    Login or Signup to reply.
    1. you need to install Android Gradle Plugin Version 7.3.1
    2. you need to install Gradle Vesion 7.5.1
    3. delete the .idea folder android /.idea it will automatically load later don’t worry don’t change file .
    4. run command Reload All from dist
    5. run Sync Project Gradle command
      these commands are at the top of File-e I have a Mac M1
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search