无法为 Flutter 项目找到 lint-gradle-api-26.1.2.jar [英] Couldn't locate lint-gradle-api-26.1.2.jar for Flutter project

查看:35
本文介绍了无法为 Flutter 项目找到 lint-gradle-api-26.1.2.jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Flutter 的新手,并在您创建新项目时尝试运行示例项目.尝试运行它时,我遇到了这个问题:

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:构建失败,出现异常.

FAILURE: Build failed with an exception.

  • 哪里:构建文件PROJECTPATH/android/app/build.gradle"行:25

  • Where: Build file 'PROJECTPATH/android/app/build.gradle' line: 25

出了什么问题:评估项目:app"时出现问题.

What went wrong: A problem occurred evaluating project ':app'.

无法解析配置类路径"的所有文件.找不到 lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2).在以下位置搜索:https://jcenter.bintray.com/com/android/tools/lint/lint-gradle-api/26.1.2/lint-gradle-api-26.1.2.jar

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

我知道它正在尝试从 jcenter 存储库中获取文件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"
  } ]
}

所以我在我的 build.gradle 文件中添加了 Google 存储库:

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

...但是我在尝试运行我的项目时仍然遇到同样的错误,无论是使用 Visual Studio Code、Android Studio 或使用 CLI.

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

如何强制 Gradle 从我找到的链接下载文件?

How do I force Gradle to download the file from the link I've found?

这是我的 build.gradle 文件的样子:

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

在顶部:

jcenter()

在文件中:.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'
    }
}

这篇关于无法为 Flutter 项目找到 lint-gradle-api-26.1.2.jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆