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
In the build.gradle Project level set classPath as follow:
in the gradle-wrapper.properties set :
Disable gradle offline mode , use VPN and sync your gradle
Option 1
You can try this
deployment > build tools > gradle
location (Example, C:/gradle/gradle7.0.4)
After this, gradle problem should fix, and try to disable gradle offline mode
Option 2
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.
I had a Flutter Project with this problem – the solution was:
/android/gradle/wrapper/gradle-wrapper.properties
distributionUrl
->distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip
That was it.
For me worked changing the Gradle JDK to Embedded JDK (JetBrains Runtime version 11.01.12) in:
these commands are at the top of File-e I have a Mac M1