I am trying to update my Android project.
I initially got this error:
ERROR: Gradle DSL method not found: 'classpath()'
Possible causes:
The project 'xxx' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 3.4.1 and sync project
So I tried this in my app's build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'io.fabric.tools:gradle:1.29.0'
}
}
But now I'm getting this error:
ERROR: Could not find com.android.tools.build:gradle:3.4.1.
What to do? Thanks for your help.
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
repositories {
....
jcenter()
...
}
buildscript {
repositories {
jcenter()
google()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
}
}
This question already has answers here:
Error: could not find com.google.gms:google-services:4.2.0
(4 answers)
Closed 4 years ago.
I get the following error in bitrise CI, although the build works find locally. I made no changes to the gradle files yet they suddenly stopper working in bitrise CI
A problem occurred configuring root project 'src'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.google.gms:google-services:3.2.1.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/google/gms/google-services/3.2.1/google-services-3.2.1.pom
https://dl.google.com/dl/android/maven2/com/google/gms/google-services/3.2.1/google-services-3.2.1.jar
https://maven.google.com/com/google/gms/google-services/3.2.1/google-services-3.2.1.pom
https://maven.google.com/com/google/gms/google-services/3.2.1/google-services-3.2.1.jar
file:/root/.m2/repository/com/google/gms/google-services/3.2.1/google-services-3.2.1.pom
file:/root/.m2/repository/com/google/gms/google-services/3.2.1/google-services-3.2.1.jar
https://maven.fabric.io/public/com/google/gms/google-services/3.2.1/google-services-3.2.1.pom
https://maven.fabric.io/public/com/google/gms/google-services/3.2.1/google-services-3.2.1.jar
https://jcenter.bintray.com/com/google/gms/google-services/3.2.1/google-services-3.2.1.pom
https://jcenter.bintray.com/com/google/gms/google-services/3.2.1/google-services-3.2.1.jar
Required by:
project :
but ./gradlew assembleDebug it works fine locally.
gradle project:
buildscript {
repositories {
google()
maven { url 'https://maven.google.com' }
maven { url 'https://dl.google.com/dl/android/maven2' }
mavenLocal()
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'io.fabric.tools:gradle:1.25.1'
}
}
allprojects {
repositories {
def androidHome = System.getenv("ANDROID_HOME")
maven { url "$androidHome/extras/android/m2repository" }
google()
maven { url "https://maven.google.com" }
maven { url 'https://dl.google.com/dl/android/maven2' }
mavenLocal()
maven { url "http://repo.commonsware.com.s3.amazonaws.com" }
maven { url "http://dl.bintray.com/populov/maven" }
jcenter()
}
}
gradle app:
apply plugin: 'com.google.gms.google-services'
What's going wrong here?
com.google.gms.google-services just disappears from google repository (at https://dl.google.com/dl/android/maven2/index.html)
Issue here => https://issuetracker.google.com/issues/120759347
A temporary workaround is to add this repository to your buildscript repositories
maven { url 'https://dl.bintray.com/android/android-tools' }
See this answer. Google Seems to be having some issues; they are currently looking into it.
The reason it works locally is because your dependancy is still cached. If you need to fix it temporarily, add the following line to your buildscript --> repositories in your main (project-level) build.gradle file. (See this other answer)
maven { url 'https://dl.bintray.com/android/android-tools' }
I'm new to Flutter and trying to run the example project when you create a new one. When trying to run it, I have this issue:
FAILURE: Build failed with an exception.
Where:
Build file 'PROJECTPATH/android/app/build.gradle' line: 25
What went wrong:
A problem occurred evaluating project ':app'.
Could not resolve all files for configuration 'classpath'.
Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
I understand it's trying to get the file "lint-gradle-api-26.1.2.jar" from the jcenter repository but when following the link I get this:
{
"errors" : [ {
"status" : 404,
"message" : "Could not find resource"
} ]
}
So I added the Google repository in my build.gradle file:
buildscript {
repositories {
maven { url 'https://dl.google.com/' }
google()
jcenter()
}
...and I also succeed to get the file by following this link:
https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar
...but I'm still getting the same error when trying to run my project, whether it is by using Visual Studio Code, Android Studio or with the CLI.
How do I force Gradle to download the file from the link I've found?
Here's how my build.gradle file looks like:
buildscript {
repositories {
//maven { url 'https://dl.google.com/dl/android/maven2/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar' }
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
jcenter()
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
jcenter()
}
}
repositories {
google()
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
jcenter()
}
....
I solved the problem by moving:
maven {
url 'https://dl.google.com/dl/android/maven2'
}
in the top of:
jcenter()
in the file: .flutter/packages/flutter_tools/gradle/flutter.gradle:
buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
Modify flutter.gradle under ./flutter/packages/flutter_tools/gradle to upgrade the tools version to 3.2.1 and add google() to the first line:
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
Screenshot of my code
Regarding this error, I just changed this line in the build.gradle file:
classpath 'com.android.tools.build:gradle:3.1.2'
to:
classpath 'com.android.tools.build:gradle:3.1.3'
And that solved my problem.
This is just a bug in the Gradle file located at C:\flutter\packages\flutter_tools\gradle\flutter.gradle at line 25.
All you have to do is just edit this file by moving it to the top:
maven {
url 'https://dl.google.com/dl/android/maven2'
}
Change from this
buildscript {
repositories {
jcenter()
maven {
url 'https://dl.google.com/dl/android/maven2'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
to this:
buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {`enter code here`
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
This is related to Flutter 0.9.4 at the moment. It will be fixed in the next release. In the meantime, you can update Flutter manually by running the commands described in "Flutter Upgrade". Basically they involve the following:
Change the Flutter GitHub channel to master by running on the command prompt:
flutter channel master
Upgrade Flutter itself by running
flutter upgrade
Once the upgrade is done, run the test drive application, and it should compile successfully.
Solution:
Put
maven {
url 'https://dl.google.com/dl/android/maven2'
}
at the top of:
jcenter()
in the file: .flutter/packages/flutter_tools/gradle/flutter.gradle :
The file is in the Flutter SDK.
this fixed my issue,SO reference here:
In your root build.gradle make sure google() is before jcenter().
repositories {
google()
jcenter()
}
In most projects you will have to update this at 2 spots.
buildscript {
repositories {
google()
jcenter()
}
}
allprojects {
repositories {
google()
jcenter()
}
}
All the previous answers resolve the problem. One comment to add is the location of the flutte.gradle.
You will find it in the directory that you installed Flutter in for the first time and not on the Flutter project.
Flutter Master Upgrade
I just had this problem. The fix for me however was a lot simpler. After switching branches to dev and upgrading, I switched back to master and it worked perfectly fine.
flutter checkout dev
flutter upgrade
Then switch back
flutter checkout master
flutter upgrade
flutter run
Just try to upgrade Flutter using the following:
flutter upgrade
(This issue has been fixed in the latest update.)
I also newbie in flutter and just installed it today. And I found the same problem as you, but after three hours googling I finally solved it.
The steps I have done are as follows:
Copy "flutter.gradle" file from "https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle" into "C:\flutter\packages\gradle"
Then modify the content, for this part:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
to:
buildscript {
repositories {
maven {
url 'https://dl.google.com/dl/android/maven2'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
In "c:\flutter\bin", run this command:
flutter channel master
Wait until finished, and then run this command:
flutter upgrade
Wait until it finished, then re-run the project to debug,
and finally the application appeared on the emulator screen.
Picture finally running
For me, opening the gradle-wrapper.properties file and editing the below line like this version solved it:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
When I encountered this error Flutter 1.0 had been released. The previous issues were fixed and still I was getting the same error.
The following steps fixed it for me :
1) Changing Gradle plugin version from 3.1.2 to 3.2.1 in your_project/android/build.gradle inside 'dependencies' section -
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
2) Changing Gradle wrapper version from 4.4 to 4.6 in your_project/android/gradle/wrapper/gradle-wrapper.properties like so
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
I have fix just by replacing these sentences:
allprojects {
repositories {
mavenCentral()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
instead of these:
allprojects {
repositories {
jcenter()
google()
}
}
in build.gradle file and then replace compile with implementation in dependencies
I have fix it with update version build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
..............
}
I have failing build on a Bitbucket CI server:
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.3.1.jar
I searched similar questions that suggested the Google Maven repository is missing, but I am not missing it. Top level build file:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
And my app level build file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
mavenCentral()
}
Try moving the google() method to the top of its execution block.
Maybe it's the order of repositories it searches in that causes the issue.
So for example, change this:
repositories {
maven { url 'https://maven.fabric.io/public' }
google() // from here
mavenCentral()
}
To this:
repositories {
google() // to here
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
If that doesn't help, instead of calling the google() method, try changing it to this:
maven {
url 'https://maven.google.com/'
name 'Google'
}
UPDATE
If all of the above didn't help - make sure your gradle version is at least 3.0.0:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
And the gradle-wrapper version is at least 4.1:
Usually located here: project_name/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
Source
Upgrading the Gradle wrapper (in gradle-wrapper.properties) to gradle-4.10.2-all.zip fixed the problem to me.
Update Gradle Version
From the android gradle release page you can check compatible version for your gradle plugin.
Update gradle version in gradle-wrapper.properties located inside yourProject/gradle/wrapper
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.0-all.zip
Plugin version Required Gradle version
2.3.0+ 3.3+
3.0.0+ 4.1+
3.1.0+ 4.4+
Note that order matters. google() should be top of any plugin repo.
For Android Studio version > 3.0
buildscript {
repositories {
google() // move it to top
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' // your Android Studio Version
}
}
allprojects {
repositories {
google() // move it to top
jcenter()
}
google() plugin is needed since Android Studio version 3.0 or higher.
For Android Studio version < 3.0
buildscript {
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0' // your Android Studio Version
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
I had an issue with gradle thinking I wanted multidex 1.0.2 so I setup the repository in the top level build file and moved it out of the buildscript (as per: Android Studio 3.0 Beta 1: Failed to resolve: com.android.support:multidex:1.0.2):
allprojects {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
}
However, Fabric seems to dislike this. In the buildscript sections of my project (and library) I have:
buildscript {
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
And now I get:
Error:Could not find any matches for io.fabric.tools:gradle:1.+ as no versions of io.fabric.tools:gradle are available.
Searched in the following locations:
file:/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository/io/fabric/tools/gradle/maven-metadata.xml
file:/Applications/Android Studio 3.0 Preview.app/Contents/gradle/m2repository/io/fabric/tools/gradle/
https://jcenter.bintray.com/io/fabric/tools/gradle/maven-metadata.xml
https://jcenter.bintray.com/io/fabric/tools/gradle/
Required by:
project :
How can I resolve this conflict? How to I specify to fabric, if not in all projects, where to get its own dependencies?
Error:Could not find any matches for io.fabric.tools:gradle:1.+ as no versions of io.fabric.tools:gradle are available.
It happens since gradle is looking for the plugin only in the jcenter repo.
To setup fabric you have to use it:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
It is required by the gradle plugin.
Then you have to add:
repositories {
maven { url 'https://maven.fabric.io/public' }
}
It is used by the dependencies added in the projects.
A colleague managed to resolve it with the following declaration in the app's build.gradle file:
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://maven.google.com' }
}