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

2019-01-02 15:29发布

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()
}

....

12条回答
时光乱了年华
2楼-- · 2019-01-02 15:44

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'
    }
}
查看更多
时光乱了年华
3楼-- · 2019-01-02 15:46

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 in 2 spots.

buildscript {
    repositories {
        google()
        jcenter()
    }

}

allprojects {
    repositories {
        google()
        jcenter()
    }
}
查看更多
姐姐魅力值爆表
4楼-- · 2019-01-02 15:51

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
查看更多
其实,你不懂
5楼-- · 2019-01-02 15:56

Just try to upgrade Flutter using the following:

flutter upgrade 

(This issue has been fixed in the latest update.)

查看更多
余生请多指教
6楼-- · 2019-01-02 15:57

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.

查看更多
千与千寻千般痛.
7楼-- · 2019-01-02 15:58

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.

查看更多
登录 后发表回答