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:
...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 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:
to:
In "c:\flutter\bin", run this command:
Wait until finished, and then run this command:
Wait until it finished, then re-run the project to debug,
and finally the application appeared on the emulator screen.
Picture finally running
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:
Upgrade Flutter itself by running
Once the upgrade is done, run the test drive application, and it should compile successfully.
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:
Change from this
to this:
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
Modify
flutter.gradle
under ./flutter/packages/flutter_tools/gradle to upgrade the tools version to 3.2.1 and addgoogle()
to the first line:Screenshot of my code
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.