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

35,615

Solution 1

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

Solution 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

Solution 3

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.

Solution 4

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

Solution 5

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:

  1. Change the Flutter GitHub channel to master by running on the command prompt:

    flutter channel master
    
  2. Upgrade Flutter itself by running

    flutter upgrade
    

Once the upgrade is done, run the test drive application, and it should compile successfully.

Share:
35,615
Hyerois
Author by

Hyerois

Hyerois πŸ“š I'm a french college student, currently doing a Two Year technical degree in chartered accounting. πŸ‡ΊπŸ‡Έ Β I'm trying to become a fluent english speaker. πŸ’» I love computing since my childhood and started programming when I was fourteen. I love : Golang ; ReactJS ; R ; working with statistics. πŸ“Œ Nice, France French editor for Genius.

Updated on July 08, 2022

Comments

  • Hyerois
    Hyerois almost 2 years

    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.

    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()
    }
    
    ....
    
    • HedeH
      HedeH over 5 years
      Maybe this will help: stackoverflow.com/a/52944600/4255978
    • Hyerois
      Hyerois over 5 years
      It didn't, still getting the same error
    • absin
      absin over 5 years
      For people coming here now, I think this has been fixed in master, so flutter channel master and flutter upgrade should sove it.
  • mano233
    mano233 over 5 years
    Upgrade your flutter, This is my environmental information and I am working now. [√] Flutter (Channel beta, v0.9.4, on Microsoft Windows [Version 10.0.17763.104], locale zh-CN) [√] Android toolchain - develop for Android devices (Android SDK 28.0.3) [√] Android Studio (version 3.2) [√] Connected device (1 available)
  • mano233
    mano233 over 5 years
    Upgrade distributionUrl=https\://services.gradle.org/distributions/g‌​radle-4.10.2-all.zip
  • Gayan Pathirage
    Gayan Pathirage over 5 years
    Thank you loads @Quentin. You saved me after 3 hours of trying various things. Gradle error seems like some dependency issue with a missing package.
  • Gaurav Sharma
    Gaurav Sharma over 5 years
    Saved me. I was facing the same issue
  • Carles
    Carles over 5 years
    Saved as well. Thanks a bunch
  • Kevin Robatel
    Kevin Robatel over 5 years
    By the way, .flutter is C:\flutter on Windows (or the location of Flutter installation). It's not linked to a project.
  • cesards
    cesards over 5 years
    You don't actually need to update the project dependencies repositories, so this answer is the one! :-D
  • martinseal1987
    martinseal1987 over 5 years
    did not see this working but definitely worked for me
  • vijju
    vijju over 5 years
    HII Aegon. I didn't find any flutter SDK. Where to find it. I have the same error?
  • Aegon
    Aegon over 5 years
    You have to download the SDK first, here is a doc explains installation. flutter.io/docs/get-started/install
  • AloDev
    AloDev over 5 years
    It is strange, but downgrading the gradle from 3.1.2 to 3.0.1(in my case) helped me.
  • Shamshun
    Shamshun about 5 years
    Actually, changing Gradle plugin version from "3.2.1" to "3.1.2" worked for me! What's going on here?
  • mohammad.pro
    mohammad.pro about 4 years
    I am struggling with this for a week and it didn't work for me, any ideas? and I have to mention that I am using a VPN because I live in a country blocked by google
  • mohammad.pro
    mohammad.pro about 4 years
    but if I click on the URL it downloads the file in the browser so actually I have the access, Can I use these files and where should I but them
  • Sajjad
    Sajjad over 2 years
    Thank you . so much . 😘😘😘.