When I run a project I get the error:
Could not find com.android.tools.build:gradle:4.1.1. Searched in the following locations:
my gradle file looks like this:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
What can I do now?
Google's Maven repository can be accessed from https://maven.google.com (an alternative URL is https://dl.google.com/dl/android/maven2/). If you are using Gradle 4.1 or higher, you can use it by adding google() to your repositories configuration in your build. gradle file.
Android Studio uses Gradle, an advanced build toolkit, to automate and manage the build process, while allowing you to define flexible custom build configurations. Each build configuration can define its own set of code and resources, while reusing the parts common to all versions of your app.
Go to your gradle-wrapper.properties file in build.gradle and you will see the last line that specifies distributionUrl. Replace distributionUrl with below one. Let the download finish and your problem will be resolved. If you want to avoid the download reduce the version of com.android.tools.build:gradle:4.1.1 this to 4.0.0+ or 3.0.0+
It seems the current versions of the Android Gradle plugin are not added to Maven Central, but they are present on jcenter. Add jcenter()to your list of repositories and Gradle should find version 2.2.3.
On the other hand, if you were able to build a new project with Android Studio 4.0.1, then Android Gradle Plugin 4.0.1 should have been downloaded and cached in your Gradle cache directories (mentioned previously), which should allow Unity editor to build using Android Gradle Plugin 4.0.1 as well.
When gradle plugin is cached, it gets placed in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle and in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api There could be other locations where things are cached inside of .gradle/caches, but these two locations are what I was able to find.
The problem here is that the android tools plugin you want to use has moved. Old distributions are in jcenter, but new ones are at "https://maven.google.com"
Update your repositories to include "https://maven.google.com"
allprojects {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
}
}
If you are in iran, china, etc... delete .gradle folder from android folder then try again with VPN.
Go to your gradle-wrapper.properties
file in build.gradle
and you will see the last line that specifies distributionUrl. Replace distributionUrl with below one.
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Let the download finish and your problem will be resolved. If you want to avoid the download reduce the version of com.android.tools.build:gradle:4.1.1
this to 4.0.0+ or 3.0.0+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With