Facing the issue while gradle sync - Could not find lint-gradle-api.jar (com.android.tools.lint:lint-gradle-api:26.1.2)

点点圈 提交于 2020-01-11 02:52:00

问题


I have updated Android Studio to 3.2.1 and now stoped on point with such issue: 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

I have tried to reorder my build.gradle file. Still, you can find the attachment here.

I have tried all the solutions.

I know this question has duplicates but their solution is not working.


回答1:


There were lots of similar issues raised the past days, that could be solved by adding the google() repository in first position in the repositories block of the build scripts. See detailed explanation in the following answers:

  • couldn't locate lint-gradle-api-26.1.2.jar for flutter project
  • Could not find play-services-basement.aar
  • https://stackoverflow.com/a/52982816/6899896
  • Could not find com.android.tools.build:aapt2:3.2.0

The root cause , related to missing libraries in Jcenter, is explained in detail here : https://stackoverflow.com/a/50885939/6899896

Note see https://stackoverflow.com/a/52947028/6899896 : you need to modify .flutter/packages/flutter_tools/gradle/flutter.gradle in addition to your project's build scripts (module & app levels) to set repo google() first and jcenter() last




回答2:


In case you're actually trying to run a Flutter project, you also need to change the order in the flutter gradle file:

<flutter directory>/packages/flutter_tools/gradle/flutter.gradle

I also updated gradle to the latest version (https://docs.gradle.org/current/userguide/installation.html) and restarted Android Studio




回答3:


TL;DR:

  1. Open <flutter_dir>\flutter\packages\flutter_tools\gradle\flutter.gradle
  2. Replace buildscript with this (the order of repositories does matter)

      buildscript {
        repositories {
          jcenter()
          maven {
            url 'https://dl.google.com/dl/android/maven2'
          }
      }
      dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
      }
    }
    



回答4:


As written in https://flutter.su/note/1, you should find a .gradle-file for your project (in Android it is usually app/build.gradle) and change (an order of repositories makes sense):

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://dl.google.com/dl/android/maven2'
        }
    }
    ...
}

...

allprojects {
    repositories {
        jcenter()

        maven {
            url "https://maven.google.com"
        }
        google()
    }
}


来源:https://stackoverflow.com/questions/52982899/facing-the-issue-while-gradle-sync-could-not-find-lint-gradle-api-jar-com-and

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!