Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couldn't locate lint-gradle-api-26.1.2.jar for Flutter project

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() }  .... 
like image 584
Hyerois Avatar asked Oct 23 '18 08:10

Hyerois


2 Answers

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'     } } 
like image 178
Hyerois Avatar answered Oct 01 '22 09:10

Hyerois


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

like image 30
mano233 Avatar answered Oct 01 '22 09:10

mano233