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