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

查看:147
本文介绍了无法为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: 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'.

无法解析配置'classpath'的所有文件. 找不到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"
  } ]
}

因此我将Google存储库添加到了build.gradle文件中:

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:

...但是尝试运行我的项目时,无论是使用

...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文件的外观:

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天全站免登陆