Error:Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2). Searched i

今日写代码时,更新完大佬的代码后,出现了一个错误,描述如下:

Error: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

废了九牛二虎之力终于解决了,特地做一下记录,下面是我的解决方法:
打开项目的 gradle ,不是app 的 gradle ,我出现问题的原因是:

上面的 google() 和 jcenter() 和下面的 google() 和 jcenter() 顺序不一致,所以出现了错误。(如果未添加,请添加代码)

改正并运行,错误便消失了,代码如下:

buildscript {
    repositories {
        google()   //与下面的顺序不要搞反了
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'

        classpath 'com.mob.sdk:MobSDK:+'
        classpath "io.realm:realm-gradle-plugin:5.7.1"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        google()  //与上面的顺序不要搞反了
        jcenter()

        maven {
            url "https://jitpack.io"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

同时我在网上也看到了别的解决方法,也有说好用的,如果上面的办法不好用,请参考下面:

在 app 的 build.gradle 加上下面代码:

 lintOptions {

        checkReleaseBuilds false
        abortOnError false
    }

猜你喜欢

转载自blog.csdn.net/wuqingsen1/article/details/84174708